Tree generator

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

Tree generator

Post by Mr. Kibernetik »

Code: Select all

#.scrclear(0.7,0.8,1)
w,h = #.scrsize()
tree(w/2,h,3*#.pi/2,h/4)

tree(x,y,a,b)=
  ? b<1, <=
  x1 = x+b*#.cos(a)
  y1 = y+b*#.sin(a)
  p = b*(#.rnd(0.15)+0.85)
  ? p<.h*0.1
    #.drawcolor(#.hsv2rgb(120,#.rnd(0.5)+0.5,#.rnd(0.6)+0.3):3,0.5)
    #.drawsize(.h/80)
    #.drawline(x,y,x1,y1)
  !
    #.drawcolor(0.6,0.25,0)
    #.drawsize(p/6)
    #.drawline(x,y,x1,y1)
    #.drawcolor(0.5,0.2,0)
    #.drawsize(p/18)
    #.drawline(x-p/18,y,x1-p/18,y1)
  .
  > i, 0..9-#.rnd(7)
    s = #.rnd(b*0.85)+b*.15
    a1 = a+0.15*(5-#.rnd(11))
    x1 = x+s*#.cos(a)
    y1 = y+s*#.sin(a)
    tree(x1,y1,a1,p-.h*0.01-#.rnd(.h*0.06))
  <
.
tree1.PNG
tree1.PNG (395.89 KiB) Viewed 2370 times
tree2.PNG
tree2.PNG (339.23 KiB) Viewed 2370 times
tree3.PNG
tree3.PNG (324 KiB) Viewed 2370 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: Tree generator

Post by rbytes »

This is a lot of fun. I created a variable called leaf, which I start at a value of 80. It sets the draw size of the leaves. Smaller values create bigger leaves and larger ones create very tiny ones so that the drawing looks more like a fern or a evergreen.

Great drawing speed from SPL.
Last edited by rbytes on Thu Sep 14, 2017 4:41 am, edited 1 time in total.
The only thing that gets me down is gravity...

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: Tree generator

Post by Mr. Kibernetik »

rbytes wrote:
Thu Sep 14, 2017 4:26 am
This is a lot of fun. I created a variable called leaf, which I start at a value of 80. It sets the draw size of the leaves. Smaller values create bigger leaves and larger ones create very tiny ones so that the drawing looks more like a fern or a evergreen.

Great drawing speed from SPL.
Any screenshots are welcome! :)

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: Tree generator

Post by rbytes »

Leaf size of 400.
Attachments
Screenshot (37).png
Screenshot (37).png (1.57 MiB) Viewed 2354 times
The only thing that gets me down is gravity...

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: Tree generator

Post by Mr. Kibernetik »

Maybe for such trees the branches width also should be made thinner...

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: Tree generator

Post by rbytes »

Yes, with a few sliders and switches this could generate endless fun.
The only thing that gets me down is gravity...

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: Tree generator

Post by Mr. Kibernetik »

Yes, sliders and switches will be added as interface objects.

Post Reply