Rose leaf

Rose leaf

Source code

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
lsystem RoseLeaf extends Branches {
 
set symbols axiom = [ < A(0,0) . > ] [ < A(0,1) . > ];
set iterations = 25;
set initialAngle = 150;
 
let LA = 5; // initial length - main segment
let RA = 1.15; // growth rate - main segment
let LB = 1.3; // initial length - lateral segment
let RB = 1.25; // growth rate - lateral segment
let LC = 3; // initial length - marginal notch
let RC = 1.19; // growth rate - marginal notch
 
interpret G(x) as DrawForward(x*0.8, 2);
interpret + as TurnLeft(60);
interpret - as TurnLeft(-60);
interpret < as StartPolygon(#007700, 2);
interpret . as RecordPolygonVertex;
interpret > as EndPolygon;
 
rewrite A(t,d) where d == 0
to . G(LA,RA,-1) . [ + B(t) G(LC,RC,t) . > ]
[ + B(t) < . ] A(t+1,d);
rewrite A(t,d) where d == 1
to . G(LA,RA,-1) . [ - B(t) G(LC,RC,t) . > ]
[ - B(t) < . ] A(t+1,d);
rewrite B(t) where t > 0
to G(LB,RB,-1) B(t-1);
rewrite G(s,r,t) where t > 1
to G(s*r,r,t-1);
rewrite G(s,r,t) where t == -1
to G(s*r,r,-1);
}
 
process all with SvgRenderer;