Barnsley fern

Post Reply
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

Barnsley fern

Post by Mr. Kibernetik »

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 1208 times

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 »

This was one of my favorites from Rosetta Code. SPL does it very well.
The only thing that gets me down is gravity...

Post Reply