Sunflower fractal: Difference between revisions

m
m (→‎{{header|Julia}}: update for changes in Makie)
 
(8 intermediate revisions by 4 users not shown)
Line 270:
End
</syntaxhighlight>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Sunflower_model}}
 
'''Solution'''
 
The method consists in drawing points on a spriral, an archimedean spiral, where two contiguous points are separated (in angle) by the golden angle.
 
Because the points tend to agglomerate in the center, they are smaller there.
 
[[File:Fōrmulæ - Sunflower model 01.png]]
 
[[File:Fōrmulæ - Sunflower model 02.png]]
 
[[File:Fōrmulæ - Sunflower model 03.png]]
 
'''Improvement'''
 
Last result is not natural. Florets in a sunflower are all equal size.
 
H. Vogel proposed to use a Fermat spiral, in such a case, the florets are equally spaced, and we can use now circles with the same size:
 
[[File:Fōrmulæ - Sunflower model 04.png]]
 
[[File:Fōrmulæ - Sunflower model 05.png]]
 
[[File:Fōrmulæ - Sunflower model 06.png]]
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
window 1, @"Sunflower Fractal", ( 0, 0, 400, 400 )
WindowSetBackgroundColor( 1, fn ColorBlack )
 
void local fn SunflowerFractal
NSUinteger seeds = 4000
double c, i, angle, x, y, r
pen 2.0, fn ColorWithRGB( 0.997, 0.838, 0.038, 1.0 )
c = ( sqr(5) + 1 ) / 2
for i = 0 to seeds
r = (i ^ c) / seeds
angle = 2 * pi * c * i
x = r * sin(angle) + 200
y = r * cos(angle) + 200
oval ( x, y, i / seeds * 5, i / seeds * 5 )
next
end fn
 
fn SunflowerFractal
 
HandleEvents
</syntaxhighlight>
[[file:Sunflower_Fractal.png]]
 
=={{header|Go}}==
Line 468 ⟶ 523:
x = r .* cos.(θ)
y = r .* sin.(θ)
f = Figure(show_axis = false)
ax = Axis(f[1, 1], backgroundcolor = :green)
scatter!(ax, x, y, color = :gold, markersize = markersizes, strokewidth = 1)
hidespines!(ax)
hidedecorations!(ax)
return f
end
Line 476 ⟶ 533:
sunflowerplot()
</syntaxhighlight>
 
{{output}}
 
[[File:Sunflower-julia.png|center|thumb]]
 
 
=={{header|Liberty BASIC}}==
Line 1,005 ⟶ 1,067:
{{trans|Go}}
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
 
2,120

edits