Sunflower fractal: Difference between revisions
m
J: cleaner implementation
(J implementation) |
m (J: cleaner implementation) |
||
Line 390:
sunfract=: {{ NB. y: number of "sunflower seeds"
phi=. 0.5*1+%:5
XY=. (y%10)+(2*(I^phi)%
XY,.(%:I)%13
}}
sunfractsvg=: {{
<svg xmlns="http://www.w3.org/2000/svg" width="%d" height="%d" style="stroke:gold">▼
<rect width="100%%" height="100%%" fill="black" />▼
</svg>▼
fract=. sunfract x
C=.,'\n<circle cx="%.2f" cy="%.2f" r="%.1f" />' sprintf fract
({{)n
(m sprintf (;/<.20+}:>./fract),<C) fwrite y▼
▲ <svg xmlns="http://www.w3.org/2000/svg" width="%d" height="%d" style="stroke:gold">
}}</lang>▼
▲ <rect width="100%%" height="100%%" fill="black" />
%s
▲ </svg>
Example use:
|