L-System Demo

An L-system or Lindenmayer system is a parallel rewriting system and a type of formal grammar. An L-system consists of an alphabet of symbols that can be used to make strings, a collection of production rules that expand each symbol into some larger string of symbols, an initial "axiom" string from which to begin construction, and a mechanism for translating the generated strings into geometric structures.

In this demonstration we use JSON to represent the system. `initial` holds the starting string or axiom. Each iteration every character in the string is replaced by the productions defined in `rules`. The final string is then interpreted geometrically by the defined `commands`. Use the slider to control the number of iterations.

You can share your creation directly from the URL bar!

Commands

        forward pixels
        back pixels
        left angle
        right angle
        moveTo x, y
        penUp
        penDown
        push
        pop
        width pixels
        style color