Barnsley fern

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

Barnsley fern

Post by Mr. Kibernetik » Tue Sep 12, 2017 10:20 pm

Code: Select all

w,h = #.scrsize()
x,y = 0
>
  r = #.rnd(100)
  ? r<85, x,y = f2(x,y)
  ? r!<85 & r<92, x,y = f3(x,y)
  ? r!<92 & r<99, x,y = f4(x,y)
  ? r!<99, x,y = f1(y)
  #.drawpoint(x/10*w+w/2,h-y/10*h,0,0.5,0,0.1)
<
f1(y) <= 0, 0.16*y
f2(x,y) <= 0.85*x+0.04*y, -0.04*x+0.85*y+1.6
f3(x,y) <= 0.2*x-0.26*y, 0.23*x+0.22*y+1.6
f4(x,y) <= -0.15*x+0.28*y, 0.26*x+0.24*y+0.44
fern.PNG
fern.PNG (241.68 KiB) Viewed 279 times

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

Re: Barnsley fern

Post by rbytes » Thu Sep 14, 2017 4:53 am

This was one of my favorites from Rosetta Code. SPL does it very well.
Zzzzz

Post Reply