Barnsley fern

Post Reply
User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Barnsley fern

Post 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 1938 times

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Barnsley fern

Post by Mr. Kibernetik »

Great looking render!

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Barnsley fern

Post by rbytes »

Wow, that is beautiful. Thanks!
The only thing that gets me down is gravity...

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Barnsley fern

Post by GeorgeMcGinn »

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)

Post Reply