overstimulate

Lindenmayer Systems in Canvas

Requires Firefox or Safari

If you don't see cool pictures, either:

  • You don't have a browser that supports canvas (get one here)
  • You don't like the fractal-like graphics

Based on a university project where I created Lindenmayer systems using postscript.

Lindenmayer Systems Overview

Lindenmayer Systems were created by a biologist, Artsid Lindenmayer to model plant growth. The basis of LSystems is string rewriting. Starting with a seed string, you iterate several generations each time following very simple rules for growing the string. During each rewriting phase, each letter is replaced by another block of letter(s).

Lets start with a seed "a", and use two rules: a -> ab and b -> a

  • Gen 0: a
  • Gen 1: ab
  • Gen 2: aba
  • Gen 3: abaab
  • Gen 4: abaababa
  • Gen 5: abaababaabaab

Things became interesting when one of his students determined that you could take this string and render it graphically. We will be treating the following characters as:

  • f means draw a line forward
  • - means rotate left
  • + means rotate right
  • [ means save state
  • ] means restore state

Examples

Weed - Rule: f -> f[+f]f[-f]f, Seed: "f"

Draw using: 1 iteration 2 iterations 3 iterations 4 iterations

Tree - Rule: f -> ff+[+f-f-f]-[-f+f+f], Seed: "f"

Draw using: 1 iteration 2 iterations 3 iterations 4 iterations

Thunderbird Icon - Rule: f -> f[+f][-f], Seed: "f"

Draw using: 1 iteration 2 iterations 3 iterations 4 iterations 6 iterations 8 iterations

Resources

More Work