In this repository, you will find all versions of the educational showcase project Python L-System Parser and Visualizer.
A Lindenmayer(L)-System is a mathematical model first invented by the Hungarian biologist and botanist Aristid Lindenmayer. An L-System works by repeatedly transforming character(s) in a string into a longer, more complex string of characters. Originally used to model the growth of bacteria and algae, L-Systems have grown to be used in textiles, games, neural networks, and art.
An L-System is composed of the following two attributes:
- Axiom / Seed: an initial starting value
- Production / Transformation Rules: definitions of how to replace each character or string into a more complex string
In the first iteration, the axiom, F, is replaced via the transformation rule for F:
In the following iterations, all of the characters in the resulting string, F + G, are again replaced by the transformation rules for both characters:
With more more complex axioms and transformation rules and increased iterations, L-System strings can grow to huge lengths.
Consider exploring Paul Bourke's L-System Manual, which was integral in my understanding of L-Systems.
A parser, in programming terms, breaks down data into smaller pieces. So, think of each character in an axiom as a piece that represents something larger (a longer string). A parser will apply transformation rules for a given number of iterations.
The visualization process is a bit more complex. In a parsed string, there are commonly:
- Variables - values that are changed in each transformation rule (usually letters)
- Constants - values that are not changed in a transformation rule, but rather define a geometric action (to turn, create a new branch, etc.)
So when a visualizer takes in a parsed string, each character is a command. Some additional requirements for a visualizer might be:
- Turn Angle - defines the angle at which to turn
- Starting Direction - defines the angle at which to start the plot; allows for rotation
Using all of this information, a visualizer is fed a parsed string and creates a complex drawing. Changing the axiom, rules, and angles allows for a plethora of possible figures to be created.
Note that some programs may be more or less complex, allowing for a range of commands/features.
Here are some examples from the second version of this project:
animation_examples.mp4
Here are some examples from my first version of this project, before I added animated visualizations:
Dragon Curve, via Paul Bourke

L-System Bush 2, via Paul Bourke

Pentaplexity, via Paul Bourke

Sierpinski Arrowhead, via Paul Bourke

Quadratic Gosper, via Paul Bourke
