Генератор деревьев

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

Генератор деревьев

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 2990 times
tree2.PNG
tree2.PNG (339.23 KiB) Viewed 2990 times
tree3.PNG
tree3.PNG (324 KiB) Viewed 2990 times

Post Reply