L-System

This page documents the development version of Graphite at dev.graphite.art, which may differ from the current release.

Grows a string by rewriting all of its symbols at once with the rules, once per generation, for drawing with the Turtle Path node.

Since every symbol with a rule is replaced in each generation, patterns repeat inside themselves at ever finer scales, like the branching of plants or the folds of fractal curves.

Interface

Inputs

ParameterDetailsPossible Types
Axiom

The string to start growing from.

Primary Input

String[]
String
Rules

One rule per line, like F = F+F-F-F+F (or F -> F+F-F-F+F), which replaces every F with F+F-F-F+F in each generation. Symbols without a rule stay as they are.

A rule can also check the symbols around one, as in A < B > C = D, which rewrites a B only between an A and a C. A rule ending with a chance from 0 to 1, like F = F[+F]F : 0.6, applies only that often and otherwise leaves the symbol as it is. The chances of a symbol's rules can add up to 1 at most.

Symbols can carry numbers, like F(10). A rule names them to work out new numbers with math, and to apply only when the condition after : holds, as in F(x) : x > 2 = F(x/2)[+F(x/2)]. A chance can be worked out from them too.

A % cuts off the rest of its branch, up to the ] that ends it.

Lines starting with // are skipped.

Default: F = F+F-F-F+F

String[]
String
Ignored Symbols

Symbols to look past when a rule checks the symbols around one, usually the turns between them.

Listing [ and ] reads the string straight through its branches, as if it had no brackets.

Default: +-

String[]
String
Generations

How many times the rules rewrite the whole string. Each generation can multiply its length.

Default: 3

Integer[]
Integer
Seed

Seed to determine unique variations on where the rules with chances apply.

Default: 0

Integer[]
Integer
Max Symbols

The longest the string may grow, in symbols, and the most generations that run. A generation past either is left out, guarding against a number of generations that would freeze the editor.

Default: 1_000_000

Integer[]
Integer

Outputs

ProductDetailsPossible Types
Result

The value produced by the node operation.

Primary Output

String
String[]