https://github.com/hunterpope03/python-l-system-parser-and-visualizer
Educational showcase project in Python that explores how L-System strings can be parsed and visualized to create geometric and botanical figures.
https://github.com/hunterpope03/python-l-system-parser-and-visualizer
education l-systems python showcase
Last synced: 7 months ago
JSON representation
Educational showcase project in Python that explores how L-System strings can be parsed and visualized to create geometric and botanical figures.
- Host: GitHub
- URL: https://github.com/hunterpope03/python-l-system-parser-and-visualizer
- Owner: hunterpope03
- Created: 2025-02-05T20:03:58.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-03-18T00:03:59.000Z (7 months ago)
- Last Synced: 2025-03-18T00:22:25.004Z (7 months ago)
- Topics: education, l-systems, python, showcase
- Language: Python
- Homepage:
- Size: 155 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Lindenmayer(L)-System Parser & Visualizer Home
In this repository, you will find all versions of the **educational showcase** project _Python L-System Parser and Visualizer_.
* [Version 1.0.0](https://github.com/hunterpope03/python-l-system-parser-and-visualizer/tree/main/v1.0.0)## What is an L-System?
A [Lindenmayer(L)-System](https://en.wikipedia.org/wiki/L-system) is a mathematical model first invented by the Hungarian biologist and botanist [Aristid Lindenmayer](https://en.wikipedia.org/wiki/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#### Consider this example:
###### Axiom = F
###### Transformation rules = F -> F + G and G -> G + H
In the first iteration, the axiom, F, is replaced via the transformation rule for F:
* ###### F -> F + GIn the following iterations, all of the characters in the resulting string, F + G, are again replaced by the transformation rules for both characters:
* ###### F + G -> (F + G) + (G + H)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](https://paulbourke.net/fractals/lsys/), which was integral in my understanding of L-Systems.
## An L-System Parser & Visualizer Program
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 rotationUsing 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.
## Example Visuals (from v1.0.0)
Here are some examples from my first version of this project:
##### Dragon Curve, via [Paul Bourke](https://paulbourke.net/fractals/lsys/)
##### L-System Bush 2, via [Paul Bourke](https://paulbourke.net/fractals/lsys/)
##### Pentaplexity, via [Paul Bourke](https://paulbourke.net/fractals/lsys/)
##### Sierpinski Arrowhead, via [Paul Bourke](https://paulbourke.net/fractals/lsys/)
##### Quadratic Gosper, via [Paul Bourke](https://paulbourke.net/fractals/lsys/)
![]()