Fern

Fern

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 StochasticPlant {
let li = 0.9; //length increase
let wi = 0.8; //width increase
let bi = 0.4; //branch increase
let angle = 45;
let td = 0.5; //decrease first branch part length
let width = 0.2;
set iterations = 7;
set initialAngle = 90;
set symbols axiom = A(10, 1, 1);
set tropismVector = {0, 1, 0};
set tropismCoefficient = 2;
rewrite A(l, w, f) where f==0
to F(l*li, w*wi)
[+A(l*li*bi, w*wi*bi, 1)]
[-A(l*li*bi, w*wi*bi, 1)]
A(l*li, w*wi, 0);
rewrite A(l, w, f) where f==1
to F(l*li*td, w*wi*td)
[+A(l*li*bi, w*wi*bi, 1)]
[-A(l*li*bi, w*wi*bi, 1)]
A(l*li, w*wi, 0);
interpret A(l, w, f) as DrawForward(l, width);
interpret B(l, w) as DrawForward(l, width);
interpret F(l, w) as DrawForward(l, width);
interpret + as TurnLeft(angle);
interpret - as TurnLeft(-angle);
interpret [ as StartBranch();
interpret ] as EndBranch();
}
process StochasticPlant with SvgRenderer;

Thumbnail extension

1
2
process all with SvgRenderer
set iterations = 5;