L-Systems

A L-System compiler written for CS 248: Interactive Computer Graphics, by Harry Sha and Ashley Nguyen. All of the below L-Systems are taken from Paul Bourke's L-System User Notes . Learn more about L-Systems here.
Our compiler is written in Python and takes a json specification of a L-System and generates an SVG.

sierpinskiArrowhead
{
  "symbols": ["X", "Y"],
  "start": "YF",
  "production_rules": {
    "X" : "YF+XF+Y"
    , "Y" : "XF-YF-X"
  },
  "turning_angle": 60
}






kolam
{
  "symbols": ["A", "B", "C", "D"],
  "start": "(-D--D)",
  "production_rules": {
    "A" : "F++FFFF--F--FFFF++F++FFFF--F"
    , "B" : "F--FFFF++F++FFFF--F--FFFF++F"
    , "C" : "BFA--BFA"
    , "D" : "CFC--CFC"
  },
  "turning_angle": 45
}






crystal
{
  "symbols": [ "F" ],
  "start": "F+F+F+F",
  "production_rules": {
    "F": "FF+F++F+F"
  },
  "turning_angle": 90
}






rings

{
  "symbols": [ "F" ],
  "start": "F+F+F+F",
  "production_rules": {
    "F": "FF+F+F+F+F+F-F"
  },
  "turning_angle": 90
}






board
{
  "symbols": [],
  "start": "F+F+F+F",
  "production_rules": {
    "F" : "FF+F+F+F+FF"
  },
  "turning_angle": 90
}






quadraticKochIsland
{
  "symbols": ["X", "Y"],
  "start": "X+X+X+X+X+X+X+X",
  "production_rules": {
    "X" : "X+YF++YF-FX--FXFX-YF+X"
    , "Y" : "-FX+YFYF++YF+FX--FX-YF"
  },
  "turning_angle": 45
}







tiles
{
  "symbols": [ "F" ],
  "start": "F+F+F+F",
  "production_rules": {
    "F": "F+F-F-FF+F+F-F"
  },
  "turning_angle": 90
}






pentaplexity
{
  "symbols": [],
  "start": "F++F++F++F++F",
  "production_rules": {
    "F" : "F++F++F|F-F++F"
  },
  "turning_angle": 36
  , "angle": 36
}






leaf
{
  "symbols": ["a", "b", "x", "y"],
  "start": "a",
  "production_rules": {
    "F": ">F<"
    , "a": "F[+x]Fb"
    , "b" : "F[-y]Fa"
    , "x" : "a"
    , "y" : "b"
  },
  "turning_angle": 45
  , "length_scale_factor" : 1.36
}






bush4
{
  "symbols": [ "V", "W", "X", "Y", "Z" ],
  "start": "VZFFF",
  "production_rules": {
    "V": "[+++W][---W]YV",
    "W": "+X[-W]Z",
    "X": "-W[+X]Z",
    "Y": "YZ",
    "Z": "[-FFF][+FFF]F"
  },
  "turning_angle": 20
}






hilbert
{
  "symbols": ["X", "Y"],
  "start": "X",
  "production_rules": {
    "X" : "-YF+XFX+FY-"
    , "Y" : "+XF-YFY-FX+"
  },
  "turning_angle": 90
}






levy
{
  "symbols": [],
  "start": "F",
  "production_rules": {
    "F" : "-F++F-"
  },
  "turning_angle": 45
  , "angle": 0
}






bush5
{
  "symbols": [ "F","X" ],
  "start": "FX",
  "production_rules": {
    "X": ">[-FX]+FX"
  },
  "turning_angle": 40,
  "length": 40,
  "length_scale_factor": 0.7
}






vonKochSnowflake

{
  "symbols": [ "F" ],
  "start": "F++F++F",
  "production_rules": {
    "F": "F-F++F-F"
  },
  "turning_angle": 60
}






bush1
{
  "symbols": ["X","Y"],
  "start": "Y",
  "production_rules": {
    "X": "X[-FFF][+FFF]FX",
    "Y": "YFX[+Y][-Y]"
  },
  "turning_angle": 25.7
}






bush2
{
  "symbols": [ "F" ],
  "start": "F",
  "production_rules": {
    "F": "FF+[+F-F-F]-[-F+F+F]"
  },
  "turning_angle": 22.5
}






bush3
{
  "symbols": [ "F" ],
  "start": "F",
  "production_rules": {
    "F": "F[+FF][-FF]F[-F][+F]F"
  },
  "turning_angle": 35
}






quadraticSnowflake
{
  "symbols": [ "F" ],
  "start": "FF+FF+FF+FF",
  "production_rules": {
    "F": "F+F-F-F+F"
  },
  "turning_angle": 90
}






squareSierpinski
{
  "symbols": ["X"],
  "start": "F+XF+F+XF",
  "production_rules": {
    "X" : "XF-F+F-XF+F+XF-F+F-X"
  },
  "turning_angle": 90
}







weeds
{
  "symbols": ["X", "Y"],
  "start": "F",
  "production_rules": {
    "F" : "FF-[XY]+[XY]"
    , "X" : "+FY"
    , "Y" : "-FX"
  },
  "turning_angle": 22.5
}






dragon
{
  "symbols": ["X", "Y"],
  "start": "FX",
  "production_rules": {
    "X" : "X+YF+"
    , "Y" : "-FX-Y"
  },
  "turning_angle": 90
}






quadraticGlosper
{
  "symbols": ["X", "Y"],
  "start": "-YF",
  "production_rules": {
    "X" : "XFX-YF-YF+FX+FX-YF-YFFX+YF+FXFXYF-FX+YF+FXFX+YF-FXYF-YF-FX+FX+YFYF-"
    , "Y" : "+FXFX-YF-YF+FX+FXYF+FX-YFYF-FX-YF+FXYFYF-FX-YFFX+FX+YF-YF-FX+FX+YFY"
  },
  "turning_angle": 90
}






hex
{
  "symbols": ["X", "Y"],
  "start": "X",
  "production_rules": {
    "X" : "X+YF++YF-FX--FXFX-YF+"
    , "Y" : "-FX+YFYF++YF+FX--FX-Y"
  },
  "turning_angle": 60
  
}






sticks
{
  "symbols": ["x"],
  "start": "x",
  "production_rules": {
    "F": "FF"
    , "x" : "F[+x]F[-x]+x"
  },
  "turning_angle": 20
}






triangle
{
  "symbols": [ "F" ],
  "start": "F+F+F",
  "production_rules": {
    "F": "F-F+F"
  },
  "turning_angle": 120
}