Jump to content

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)%seedsy) * +.^j.2*1p1*phi*I=.1+i.y
XY,.(%:I)%13
}}
 
sunfractsvg=: {{)n
<svg xmlns="http://www.w3.org/2000/svg" width="%d" height="%d" style="stroke:gold">
<rect width="100%%" height="100%%" fill="black" />
%s
</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>
(m}} sprintf (;/<.20+}:>./fract),<C) fwrite y}}
}}</lang>
 
Example use:
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.