L-System Visualizer

Drive turtle graphics from a short axiom plus rewrite rules. Each iteration expands every symbol in parallel. You see the final polyline scaled to the canvas, string length, stroke color you pick.

String length: 0Depth: 4
Grammar
AxiomStarting string before any rewrite.
RulesOne rule per line. Use F=FF or F -> FF. Single-letter heads only.
Geometry
Turn angle (degrees)
Step
Heading
Stroke
Iterations 4
Starter shapes
Expanded string (debug)

One extra iteration often multiplies symbol count far more than newcomers expect. If the page stutters, drop depth first, then shorten rules.

Heads up. This page applies classic turtle semantics on a square canvas. Brackets push position plus heading, pop restores them. Symbols outside the turtle alphabet are ignored for motion but still ride through rewrites.

When the string grows faster than patience

Lindenmayer systems rewrite every symbol in the current string at once. Two short rules plus six iterations routinely cross tens of thousands of characters. The visualizer still draws, yet your device fans tell the truth.

We cap depth at eight so casual browsers avoid accidental freezes. For publication-quality exports you would still export vector data elsewhere. Here the goal is quick feedback while you learn how axiom choice steers the silhouette.

Motion alphabet (this tool)

F or G
Step forward while drawing a segment.
f
Step forward without ink (pen up).
+
Rotate left by the turn angle you set.
-
Rotate right by the same angle.
[
Save position plus heading.
]
Restore the last saved state.

Any other single character (for example X or Y) is a structural placeholder you rewrite until only motion symbols remain, or until you stop iterating.

Rewriting without hand-waving

You type an axiom, list productions with = or ASCII arrow, then pick iterations. The engine expands left-to-right, substituting each head symbol with its body or leaving it unchanged when no rule exists. After expansion, the turtle walks the final string once.

Auto-fit measures every vertex the turtle visits, then scales plus centers the polyline inside the frame. Shrinking step length does not shrink the overall shape forever. It changes local detail density while bounds tracking keeps the whole figure visible.

Same family, different front door

If you want grammar editing without the scaling stage, open the L-System Fractal Generator. Prefer classic snowflake geometry with dedicated sliders? Use the Koch Snowflake Generator. Branching silhouettes without writing productions first appear in the Fractal Tree Generator.

Preset cheat sheet

TileAxiomAngleNotes
KochF60°Three-fold snowflake spine.
SierpinskiF-G-G120°Two symbols, two productions.
PlantX25°Heavy brackets, organic feel.
TreeF25.7°Symmetric branching.
FernX25°Longer expansion than plant preset.
DragonFX90°Uses helper symbols X, Y.

Brackets behave like a stack, not decoration

Every opening bracket freezes the turtle where it stands. The interpreter pushes x, y, heading. A closing bracket teleports back without drawing a connecting segment. Botanists used this trick long before GPU instancing: one stem forks, draws a twig, returns, draws another twig.

If your plant looks like a scribble, count brackets. Odd depth usually means a missing closer or an extra opener on one production line. The turtle never guesses intent. It only executes the expanded string in order.

What this page refuses to do

There is no stochastic rule picker, no 3D turtle, no texture export. Stochastic L-systems need random seeds per run. 3D needs another rotation command set. You also will not find file upload: the grammar lives in the textarea only.

Processing stays in your tab. Clear the canvas when you finish if someone else uses the machine. The expanded string panel is optional eyeballing for students tracing symbol blow-up.

Visualizer questions we see often

Short answers tied to this turtle implementation.

Why does my curve vanish after I change heading?

Auto-fit recomputes bounds from every drawn vertex. Spinning the heading rotates the whole polyline. If every segment collapses to a dot because rules never emit F or G, you will see an empty frame. Add a motion symbol or raise iterations so placeholders unfold.

Do spaces inside rules matter?

Leading or trailing spaces on each line are trimmed. Spaces inside the replacement string count as literal characters, which usually breaks single-letter turtle commands. Keep productions tight unless you intentionally embed blanks.

Why is dragon slower than Koch at the same iteration count?

Dragon-style axioms mix two non-drawing symbols before the string fills with turns and steps. Length grows faster than intuitive estimates, so the turtle executes more commands per depth step. Drop depth or lighten step length before blaming hardware.

Does Toolexe store my grammar?

No server round trip runs here. The script reads your fields, expands the string in memory, paints the canvas, and stops. Refreshing the page clears everything unless your browser restores form fields.