-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree-1.lpy
87 lines (64 loc) · 1.63 KB
/
tree-1.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from random import uniform as uni
from random import randint as rint
fprob = 0.3
len = 10
generation = 0
bw = 0.6
fisize1, fisize2 = 0.2, 0.4
fosize1, fosize2 = 0.1, 0.2
lisize1, lisize2 = 0.1,0.9
losize1, losize2 = 0.25, 0.75
Axiom: SetWidth(0.5) @Gc trunk() tree(1) @Ge
derivation length: 125
production:
trunk():
nproduce (
F(1,bw)curve(15,15)
F(1.5,bw-0.1)curve(15,15)
F(1,bw-0.15)curve(15,15)
F(1,bw-0.2)curve(15,15)
F(1,bw-0.25)curve(15,15)
F(2,bw-0.32)curve(15,15)
F(1,bw-0.35)curve(15,15)
)
tree(t):
nproduce (
curve(15,15)F(uni(0.3,1))
[
[
F(uni(0.01,0.2))-(90)arm(t)]
F(uni(0.01,0.2))[+(90)arm(t)]
F(uni(0.01,0.2))[^(90)arm(t)]
F(uni(0.01,0.2))[&(90)arm(t)]
]
)
if t<len:
produce tree(t+1)
else:
for _ in range(4):
nproduce [arm(4)]
arm(t):
nproduce [curve(25,25)branch(t)]branch(t)
if t<len:
produce arm(t+1)
branch(t):
nproduce SetWidth(min(0.3/t,0.1))+(uni(-25,25)) &(uni(-25,25)) F
for _ in range(2):
nproduce leaf(lisize1, lisize2, losize1, losize2) [fruit(fisize1,fisize2,fosize1,fosize2)]
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):
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