Grass

Grass

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
lsystem Grass {
 
let angle = 14;
let thickness = 0.1;
 
set iterations = 8;
set initialAngle = random(80, 110);
set tropismVector = {0, -1, 0};
set tropismCoefficient = 2;
set symbols axiom = A(10);
 
rewrite A(x) where x<10 to F(x*0.75)[+A(x*0.5)]B(x) weight 5
to F(x/2)[+F(x)] weight 1;
rewrite A(x) to F(x*0.75)[+A(x*0.5)]B(x);
 
rewrite B(x) where x<10 to F(x*0.75)[-B(x*0.5)]A(x) weight 5
to f weight 1;
rewrite B(x) to F(x*0.75)[-B(x*0.5)]A(x);
 
interpret F(x) as DrawForward(x, thickness);
interpret A(x) as DrawForward(x, thickness);
interpret B(x) as DrawForward(x, thickness);
interpret + as TurnLeft(angle);
interpret - as TurnLeft(-angle);
interpret [ as StartBranch();
interpret ] as EndBranch();
}
 
process Grass with SvgRenderer;

Thumbnail extension

1
2
process all with SvgRenderer
set iterations = 5;