Tree generator

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

Tree generator

Post by Mr. Kibernetik » Wed Sep 13, 2017 8:32 pm

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 449 times
tree2.PNG
tree2.PNG (339.23 KiB) Viewed 449 times
tree3.PNG
tree3.PNG (324 KiB) Viewed 449 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: Tree generator

Post by rbytes » 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.
Last edited by rbytes on Thu Sep 14, 2017 4:41 am, edited 1 time in total.
Zzzzz

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

Re: Tree generator

Post by Mr. Kibernetik » Thu Sep 14, 2017 4:30 am

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

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

Leaf size of 400.
Attachments
Screenshot (37).png
Screenshot (37).png (1.57 MiB) Viewed 433 times
Zzzzz

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

Re: Tree generator

Post by Mr. Kibernetik » Thu Sep 14, 2017 4:48 am

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

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

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

Yes, with a few sliders and switches this could generate endless fun.
Zzzzz

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

Re: Tree generator

Post by Mr. Kibernetik » Thu Sep 14, 2017 4:53 am

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

Post Reply