Animated Sierpinski trangle

Animated Sierpinski trangle

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
lsystem SierpinskiTrangle {
 
set symbols axiom = < . F . + F . + F >;
set iterations = 8;
set interpretEveryIteration = true;
 
 
interpret F f as MoveForward(2 ^ -currentIteration * 600);
interpret + as TurnLeft(120);
interpret - as TurnLeft(-120);
interpret < as StartPolygon(0, 0);
interpret . as RecordPolygonVertex;
interpret > as EndPolygon;
 
rewrite F to < . F . + F . > + f + f F;
rewrite f to f f;
rewrite < to nothing;
rewrite . to nothing;
rewrite > to nothing;
}
 
process all with AnimationRenderer;