- formal grammar which is an alphabet of symbols used to make strings and a mechanism for translating those strings into geometric structures.
- Common conventions in using l-systems for drawing:
// 2d drawing F : move forward and draw a line (with some pre-defined length) f : move forward without drawing a line (with a pre-defined length) E : draw a an ellipse (with a pre-defined length) + : turn left (by a pre-defined angle) - : turn right (by a pre-defined angle) ~ : turn randomly every time // 3d drawing / : Rotate around Y axis, in the positive direction \ : Rotate around Y axis in negative direction & : Rotate around X axis, in the positive direction ^ : Rotate around X axis in negative direction
- you can branch by segmenting them with
[]which is basically enclosing them in their own separate “function” - you can also create your own functions on top of symbols to give them modifiable properties, i.e.
F(x) : move forward by x units and draw a line along the way f(x) : move forward by x units *without* drawing a line along the way +(a) : turn left by a degrees -(a) : turn right by a degrees
Implementation
To draw, you usually use p5js, but I like how bhavik has made an editor that automatically converts the grammar into something useful.