This simulation grows Lindenmayer systems: an axiom string is rewritten over several iterations using production rules, where each symbol is replaced by its replacement string in parallel. The final string is read as turtle-graphics commands. F and G draw a forward segment, plus and minus turn by the chosen angle, and square brackets push and pop the turtle's position and heading onto a stack, producing branches.
The Preset menu loads ten classic systems such as the Fractal Plant, Koch snowflake, Dragon curve, Hilbert curve and Barnsley-style fern. The Iterations slider sets rewriting depth, Angle controls turn size, and Line length scales each segment. Draw renders the result while Animate growth reveals segments progressively. L-systems underpin procedural modelling of plants, trees and natural branching in graphics and biology.
What is an L-system?
An L-system, or Lindenmayer system, is a formal grammar that rewrites a starting string called the axiom by applying production rules repeatedly. The resulting string is interpreted geometrically, most often as turtle-graphics drawing commands. It was devised by biologist Aristid Lindenmayer in 1968 to model plant growth.
How does the rewriting actually work?
Each iteration scans the current string and replaces every symbol with its rule's right-hand side simultaneously, leaving symbols without a rule unchanged. For example, with rule F to FF the string F becomes FF, then FFFF, and so on. This parallel substitution is what distinguishes L-systems from ordinary sequential grammars.
What do the symbols in the rules mean?
In this simulator F and G move the turtle forward and draw a line, while A and B move forward without drawing for space-filling curves. The plus and minus signs turn the heading right and left by the angle, and the brackets push and pop the turtle's state to create branches that return to a saved point.
Iterations sets how many times the rules are applied, so higher values yield exponentially longer strings and more detail. Angle is the turn size in degrees applied at each plus or minus. Line length scales every forward segment in pixels, changing the overall size before the view auto-fits the canvas.
Because each iteration can multiply the string length by the average rule size, growth is roughly exponential. A system with rule F to FF doubles every step, so nine iterations can produce hundreds of thousands of characters. The code caps strings at about 1.5 million symbols to keep the browser responsive.
Turtle graphics is a drawing model where an imaginary turtle moves across the canvas carrying a pen. Commands tell it to move forward, turn by an angle, or lift and lower the pen. By translating L-system strings into these movements, abstract symbol sequences become visible curves and branching plant shapes.
An opening bracket saves the turtle's current position and heading onto a stack, and a closing bracket restores them. This lets a branch grow, then return the turtle to where the branch began so a sibling branch can start. Nested brackets create the recursive, self-similar branching seen in the Fractal Plant and Bush presets.
Many presets reproduce genuine mathematical fractals, including the Koch curve, Sierpinski triangle, Dragon curve, Levy C curve and Hilbert space-filling curve. At infinite iterations these have well-defined fractal dimensions. On screen we render a finite approximation, since only a limited number of rewriting steps can be drawn.
Real plants develop through repeated, self-similar branching governed by local growth rules, which is exactly what bracketed L-systems encode. Choosing botanically plausible angles near 20 to 25 degrees and rules that split into left and right branches mimics phyllotaxis and apical growth, so the output resembles ferns, bushes and trees.
L-systems are widely used in computer graphics to generate trees, foliage and vegetation procedurally for films and games, avoiding the need to model every plant by hand. They also appear in biological modelling of growth, in generative art, and in algorithms for synthesising plausible road networks and city layouts.
Lindenmayer rewriting rules grow lifelike plants, fractal curves and space-filling patterns. 10 presets include Koch curve, Hilbert curve, Dragon curve, Barnsley fern and Sierpinski triangle.
A string is repeatedly rewritten using production rules. The resulting string is interpreted as turtle graphics commands: move forward, turn left/right, push/pop position.
Choose a preset or write custom rules. Adjust iteration depth, angle and segment length. Watch the L-system evolve from simple axiom to complex structure.
L-systems were invented by biologist Aristid Lindenmayer in 1968 to model plant cell growth. They can describe everything from algae branching to tree canopies to city street layouts.