L-System

L-system string rewriting and turtle graphics: Koch, dragon, plant presets, and custom grammars.

About this tool

Rewrite and inspect a turtle path

Choose a preset or enter an axiom and productions, then Draw. Rewriting is parallel: every symbol in the old word is replaced once per round. Symbols without productions remain unchanged. Empty rules are valid; an empty right side erases its symbol. Use one Unicode symbol at the left of =, -> or →. Lines beginning with # are comments; malformed or repeated productions are errors rather than silently skipped. The optional output shows the actual resulting word.

Turtle meaning

F,A,B draw one step; f,G move without drawing. + and − turn in opposite directions by the selected angle; + direction is selectable. | reverses heading. [ saves position/heading and ] restores them without a connecting line. Unknown symbols are nondrawing grammar variables. Coordinates are Cartesian with positive y upward; heading0 points right and90 points up. Presets choose sensible headings, including an upright plant.

Model step is an arbitrary geometric unit, not screen pixels. The complete path is uniformly fitted to the image; changing step usually changes raw coordinates rather than the fitted shape. CSV keeps those coordinates. The5-segment90° preset is the quadratic Koch variant; the snowflake uses the standard4-segment60° production. No fractal dimension is inferred from the picture.

Budgets and exports

0–14 rounds and350000 Unicode symbols are supported, including the initial word. An over-budget expansion returns no partial picture. Computation uses short batches with true progress and Cancel. No automatic calculation on loading; resize/theme redraw the accepted geometry. Editing input clears old outputs. Bracket/numeric-range errors are explicit; empty/nondrawing words remain inspectable without pretending to have a path.

PNG captures current pixels and grammar parameters. SVG contains normalized equally scaled path geometry and JSON metadata; CSV contains raw segment endpoints. Pen-up/branch jumps remain separate. Draft grammar and valid numeric settings persist on tool reentry, results start empty. Double/finite rewriting, not a measured biological model or arbitrary stochastic/3D grammar.