'Barnsley fern
'by Dutchman, december 2016
' --- constants
maxpoints=1e6
GET SCREEN SIZE sw,sh
gain=sh/5.5
x0=0.8*sw ! y0=0
' --- initialise graphics
GRAPHICS
GRAPHICS CLEAR 0,0,0.5
DRAW COLOR 0,1,0
' --- draw
FOR n=1 TO maxpoints
p=RND(1)*100
IF p<=1 THEN
nx=0
ny=0.16*y
ELSE
if p<=8 THEN
nx=0.2*x-0.26*y
ny=0.23*x+0.22*y+1.6
ELSE
if p<=15 THEN
nx=-0.15*x+0.28*y
ny=0.26*x+0.24*y+0.44
ELSE
nx=0.85*x+0.04*y
ny=-0.04*x+0.85*y+1.6
ENDIF
ENDIF
ENDIF
x=nx
y=ny
DRAW pixel x0+x*gain,y0+y*gain
NEXT n
END
This is a very elegant mathematical formula describing a fern.
I love it!
George.
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)