L-System

Rewrite an axiom with Lindenmayer production rules over N generations, then draw the result with a turtle.

What it does

L-System grows a fractal or branching shape in one of two ways.

From a typed grammar. A starting string (the axiom) is rewritten by a set of symbol-replacement rules, once per iteration, and the result is walked with a turtle: forward moves draw a line, +/- turn, and [/] branch and return. Pick a built-in preset (Sierpinski, Koch, Dragon, Hilbert 2D, Plant, Hilbert 3D, Tree 3D), or set Preset to Custom and write your own axiom and rules. More iterations means more rewrite passes, a denser and more detailed pattern, and more points.

From a drawn generator. Wire a path from Pen or Edit into the Generator input and that drawn path becomes the rule: every segment of the path is replaced by a shrunken copy of the whole path, repeatedly, so a single bump turns into a Koch-style fractal. Editing the drawn path upstream regenerates the fractal live. With a generator wired, the axiom, rules, and preset are ignored. Iterations sets how deep the substitution recurses.

The same turtle draws the line either way. In 2D mode it draws a flat vector shape. In 3D mode it draws a polyline in the scene and turns can pitch and roll out of the plane, which is what the Hilbert 3D and Tree 3D presets use to fill space and fan branches. Angle, Step, and Width Scale can each be wired from a Distance Field or Gradient instead of held constant, so the pattern bends, stretches, or thins as it walks across a field. Every visited position is also emitted as points, ready to drive instancing.

When to use it

ParameterTypeDefaultWhat it does
angle_fieldScalar Field or Number—Spatial angle override — Field evaluated at turtle position (radians). Disconnected = use constant angle.
step_fieldScalar Field or Number—Spatial step override — Field evaluated at turtle position. Disconnected = use constant step.
width_fieldScalar Field or Number—Spatial width scale override — Field evaluated at turtle position. Disconnected = use constant width_scale.
generatorCollection—Optional drawn generator path (Pen / Edit). Wired = that path IS the rule (edge-rewritten recursively); disconnected = use the axiom + rules grammar.
presetString"Custom"Pick a built-in L-System or 'Custom' to use the axiom/rules/angle below. One of: Custom, Sierpinski, Koch, Dragon, Hilbert 2D, Plant, Hilbert 3D, Tree 3D.
axiomString"F"Starting symbol string (used when preset is 'Custom').
rulesString"F=F+F-F-F+F"Rewrite rules, one per line: '<symbol>=<replacement>'. Blank lines and '#'-prefixed comments are ignored. Used when preset is 'Custom'.
iterationsNumber4Number of rewrite passes. Each pass applies all rules in parallel.
modeString"2D"2D turtle on XY plane, or 3D turtle with pitch/roll. One of: 2D, 3D.
stepNumber10Default distance for forward movement
angleNumber90Default rotation angle for +/- commands. Overridden by preset when preset is not 'Custom'.
initial_headingNumber90Initial turtle heading (degrees from +X axis)
output_originString"Centered"Output positioning: Origin places turtle start at (0,0), Centered centers the result. One of: Origin, Centered.
initial_widthNumber2Initial stroke width
width_scaleNumber0.700Width multiplier when ! is encountered
stroke_colorColorrgba(1.00, 1.00, 1.00, 1.00)Line color
max_pointsNumber100000Maximum number of points to generate (prevents runaway L-Systems)
opacityNumber1Layer opacity (0 = transparent, 1 = opaque). Editable, wirable, keyframable.

Gotchas

Iterations grows the shape exponentially, whether a grammar is being expanded or a drawn generator recursed. Max Points caps the turtle's output so a runaway setting cannot hang the graph; raise it deliberately if a dense preset (Plant at high Iterations) or a many-segment drawn generator gets clipped.

Only one visual output is drawn at a time: 2D mode draws Shapes, 3D mode draws Geometry, never both. Switch Mode to change which one is live. Points is always produced but never draws on its own, being instancing data for a downstream node.

Wiring the Generator input switches the node into drawn-generator mode: the drawn path becomes the rule and the Axiom, Rules, Preset, and Angle fields no longer apply. Disconnect it to return to the typed grammar.

When Preset is anything other than Custom, the built-in axiom, rules, and angle take over and the Axiom, Rules and Angle fields are ignored. Set Preset to Custom to use your own values. This applies to the typed-grammar mode only, since a wired Generator overrides all of them.

Rules take one line per symbol, symbol=replacement. Blank lines and lines starting with # are ignored, so a grammar can carry comments. A symbol with no rule passes through unchanged each pass.

Worked example

  1. Add an L-System node. Leave Preset on Sierpinski to see a result immediately.

  2. Raise Iterations to add detail, watching point count and render time grow fast.

  3. Set Preset to Custom, then write your own Axiom (e.g. F) and Rules (e.g. F=F+F-F-F+F) to design a new pattern.

  4. Switch Mode to 3D and pick Hilbert 3D or Tree 3D for a spatial structure whose turns pitch and roll out of the plane.

  5. Alternatively, draw a shape with Pen, wire it into Generator, and raise Iterations to turn the sketch into a fractal. Edit the sketch and it regenerates live.

  6. Wire a Gradient into Step Field to make the stride vary across the canvas.

  7. Adjust Stroke Color, Initial Width, and Width Scale to style the line.

See also

Pen · Pattern · Noise · Geometry (meshes)