Page 1 of 1

Barnsley fern

Posted: Sat Dec 31, 2016 9:57 pm
by Dutchman
Another item of Rosetta's tasks, my last one of this year :D

Code: Select all

'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
Please post it on Rosetta's if you can :P
Barnsley fern.PNG
Barnsley fern.PNG (264.53 KiB) Viewed 1939 times

Re: Barnsley fern

Posted: Sat Dec 31, 2016 10:06 pm
by Mr. Kibernetik
Great looking render!

Re: Barnsley fern

Posted: Sat Dec 31, 2016 10:33 pm
by rbytes
Wow, that is beautiful. Thanks!

Re: Barnsley fern

Posted: Tue Jan 03, 2017 2:30 am
by GeorgeMcGinn
This is a very elegant mathematical formula describing a fern.

I love it!

George.