Skip to content

An implementation of Bresenham's line and circle drawing algorithms and deterministic context-free L systems

Notifications You must be signed in to change notification settings

amalad/Lindenmayer-Systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

L Systems

An implementation of Bresenham's line and circle drawing algorithms and deterministic context-free L systems

Following are few of the results produced:

  1. A Gulmohar-like tree:

    Axiom: S

    Production rules:

                     S -> FB
                     B -> F[+BLMR]F[-BMR]F[+BL][-BLMR]
                     F -> FN
                     N -> F
                     L -> [G-G][-G+G]--[G-G][-G+G]++++[G-G][-G+G]--
                     R -> Y[MP][/MP][\MP]
    

    Phenotypes:

                     F -> (DRAW_FORWARD, 10.0, brown)
                     G -> (DRAW_FORWARD, 5.0, green)
                     M -> (MOVE_FORWARD, 2.0)
                     Y -> (DRAW_CIRCLE, 1.0, yellow)
                     P -> (DRAW_CIRCLE, 2.0, red)
                     [ -> (SAVE)
                     ] -> (RETURN)
                     + -> (ROTATE, +22.5)
                     - -> (ROTATE, -22.5)
                     / -> (ROTATE, -36)
                     \ -> (ROTATE, 36)
    

    Results:

    n=3 n=5 n=7

  2. A blueberry plant:

    Axiom: S

    Production rules:

                     S -> B
                     B -> FL[++LBLMR]FL[+BLMR]--FLR[BLMR]++
                     L -> //[G/G][/G\G]\[G/G][/G\G]\\[G/G][/G\G]\[G/G][/G\G]//
                     R -> Y[MP][//MP][////MMP][\\MP][\\\\MMP]
    

    Phenotypes:

                     F -> (DRAW_FORWARD, 20.0, brown)
                     G -> (DRAW_FORWARD, 7.0, green)
                     M -> (MOVE_FORWARD, 2.0)
                     P -> (DRAW_CIRCLE, 2.0, indigo)
                     [ -> (SAVE)
                     ] -> (RETURN)
                     + -> (ROTATE, +15)
                     - -> (ROTATE, -15)
                     \ -> (ROTATE, +22.5)
                     / -> (ROTATE, -22.5)
    

    Results:

    n=2 n=4 n=6

  3. Dried Grass:

    Axiom: W

    Production rules:

                     V -> [+++W][---W]YV
                     W -> +X[-W]Z
                     X -> -W[+X]Z
                     Y -> YZ
                     Z -> [-FFF][+FFF]F
    

    Phenotypes:

                     F -> (DRAW_FORWARD, 7.5, brown)
                     [ -> (SAVE)
                     ] -> (RETURN)
    

    Results:

    n=2 n=4 n=6 n=8

About

An implementation of Bresenham's line and circle drawing algorithms and deterministic context-free L systems

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages