34 lines
817 B
Text
34 lines
817 B
Text
void local fn BarnsleyFern( height as long )
|
|
double x = 0, y = 0, xn, yn, f = height / 10.6
|
|
long n, r, offsetX = height / 4 - height / 40
|
|
|
|
for n = 1 to height * 50
|
|
r = rnd(100) - 1
|
|
select
|
|
case r >= 0 && r <= 84
|
|
xn = 0.85 * x + 0.04 * y
|
|
yn = -0.04 * x + 0.85 * y + 1.6
|
|
case r >= 85 && r <= 91
|
|
xn = 0.2 * x - 0.26 * y
|
|
yn = 0.23 * x + 0.22 * y + 1.6
|
|
case r >= 92 && r <= 98
|
|
xn = -0.15 * x + 0.28 * y
|
|
yn = 0.26 * x + 0.24 * y + 0.44
|
|
case else
|
|
xn = 0
|
|
yn = 0.16 * y
|
|
end select
|
|
|
|
x = xn : y = yn
|
|
pen -1
|
|
oval fill (offsetX + x * f, height - y * f, 1.5, 1.5), _zGreen
|
|
next
|
|
|
|
end fn
|
|
|
|
window 1, @"Barnsley fern", (0,0,300,600)
|
|
WindowSetBackgroundColor( 1, fn ColorBlack )
|
|
|
|
fn BarnsleyFern( 600 )
|
|
|
|
HandleEvents
|