Elm – fun with L-System (Part 6)


  1. Algae
  2. Pythago­ras Tree
  3. Can­tor Dust
  4. Koch Curve
  5. Sier­pin­ski Tri­an­gle
  6. Drag­on Curve (this)
  7. Frac­tal Plant

Last time out we imple­mented the Sier­pin­s­ki Tri­an­gle exam­ple from the L-Sys­tem wikipedia page. Now, let’s con­tinue our jour­ney and see how we can imple­ment the (rather impres­sive sound­ing) Drag­on Curve exam­ple in Elm.


Example 6 : Dragon Curve

First, let’s define our L-Sys­tem:


Again, thanks to the work we did in Part 4, our work here is rather sim­ple:


which is a pret­ty straight trans­la­tion of:

  • F’ : draw for­ward
  • –’ : turn left 90 degrees
  • +’ : turn right 90 degrees
  • X’ and ‘Y’ : ignore

Unlike the oth­er L-Sys­tems, this one grows much slow­er and as it slows it does make a nice pic­ture!



Live Demo (here)

Use LEFT and RIGHT arrow keys to evolve/devolve the L-Sys­tem.

Source Code (here)



Next : Frac­tal Plant