Koch Curve · depth=4 · θ=90° · len=341
The Math Behind This Drawing

Every number below updates live as you change the system, so this always describes exactly what's on screen.

What an L-system is

A Lindenmayer system rewrites a string of symbols in parallel: starting from an axiom, every symbol in the string is replaced at once, every generation, according to a fixed set of production rules — not one symbol at a time, like most formal grammars. Formally, a system is a triple G = (V, ω, P): an alphabet V, an axiom ω, and rules P. Iterating the rules a few times turns a short seed into a long string that a turtle can draw.

Turtle interpretation

F, G — move forward, drawing a line
f, g — move forward without drawing
+ — turn left by the angle θ
— turn right by the angle θ
[ — push the current position & heading onto a stack
] — pop a position & heading off the stack
anything else — ignored by the turtle (bookkeeping symbols only)

This system
Axiom & rules

Variations not built into this tool

Three well-known extensions to the basic grammar above: context-sensitive systems, where a rule only fires when its symbol has specific neighbors (e.g. "b < a > c → aa" rewrites a only between b and c); stochastic systems, where a symbol has several possible replacements, each chosen by chance every generation; and parametric systems, where symbols carry numeric parameters (e.g. a(x,y)) that rules can read and rewrite. This tool sticks to plain deterministic, context-free rules (a "D0L system").

Grammar & turtle conventions from the Wikipedia L-system article. "Randomize system" is adapted from ehrenjn's L-Systems visualizer (guarantee-at-least-one-F, and blending curated "nice" angles with fully random ones).

System
Rules
Growth
Iterations4
Line width1.6
Color
#f2a65a
Brightness0.90
Glow intensity8
Glow
Motion
Reveal animation
Speed1.0x
Explore

Grammar from the Wikipedia L-system article. Random-system generation adapted from ehrenjn's L-Systems visualizer.

Drag to pan · Scroll to zoom · Double-click to reset view
Gear = tune the system · Σ = explain the math