Генератор деревьев
Posted: 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))
<
.