-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree-4.lpy
62 lines (41 loc) · 1.37 KB
/
tree-4.lpy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from random import uniform as uni
from random import randint as rint
crvA1 = 50
crvA2 = 90
fprob = 0.1
fisize1, fisize2 = 0.1, 0.7
fosize1, fosize2 = 0.3,0.6
lisize1, lisize2 = 0.1,0.9
losize1, losize2 = 0.1,2
Axiom: SetWidth(0.5) SetColor(60,60,50) curve(15,15) F(8,0.2) A(5)
derivation length: 50
production:
A(t):
nproduce SetWidth(0.08*(t**0.5))randrot(-180,180,0,40)F(3)[upBranch(5)]
if t > 0 :
produce A(t-1)
upBranch(t):
nproduce [upCurve(rint(3,6),rint(crvA1,crvA2),rint(3,6))]/(uni(-180,180))upCurve(rint(3,6),rint(crvA1,crvA2),rint(3,6))
if t > 0 :
produce upBranch(t-1)
upCurve(k, r, a):
nproduce ptUp() +(r)F(uni(0.1,2))
for _ in range(k):
nproduce -(a+uni(-5,5))F(uni(0.1,2))[randrot(-180,180,0,40) F leaf(lisize1, lisize2, losize1, losize2) [fruit(fisize1, fisize2, fosize1, fosize2, fprob)]]
leaf(isize1, isize2, osize1, osize2):
nproduce [[;randrot(-180,180,0,40)~l(uni(0.1,1))]F(uni(isize1, isize2))[;randrot(-180,180,0,40)~l(uni(osize1, osize2))]]
fruit(isize1, isize2, osize1, osize2, fprob):
if uni(0,1) < fprob:
nproduce SetWidth(0.01)ptDw()-(uni(-15,15))F(uni(isize1, isize2));;@O(uni(osize1, osize2))..
else:
produce
ptUp():
produce PinpointRel(0,0,1)
ptDw():
produce PinpointRel(0,0,-1)
curve(r,p):
nproduce -(rint(-r,r))&(rint(-p,p))
randrot(r1,r2,t1,t2):
produce /(uni(r1,r2))+(uni(t1,t2))
interpretation:
endlsystem