Skip to content

antigones/LSystems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

L-System

A class to draw curves expressed as L-System production rules

koch_omega = "F"
koch_expansion_rules = { 
"F":"F+F-F-F+F",
"+":"+",
"-":"-"
}
koch = LSystem(koch_omega, koch_expansion_rules, 90, 3)
koch.print_pattern()
  • omega: the axiom
  • expansion_rules: the set of expansion rules
  • angle: the angle to turn when turning left or right
  • time: the number of iteration

koch curve

Usage example

fractal_plant_omega = "X"
fractal_plant_expansion_rules = {
  "X":"F+[[X]-X]-F[-FX]+X",
  "F":"FF",
  "[":"[",
  "]":"]",
  "+":"+",
  "-":"-"
}
fractal_plant = LSystem(fractal_plant_omega, fractal_plant_expansion_rules, 25, 4)
fractal_plant.print_pattern()

generated plant

dragon_curve_omega = "F"
dragon_curve_expansion_rules = {
  "F":"F+G",
  "G":"F-G",
  "+":"+",
  "-":"-"
}
dragon_curve = LSystem(dragon_curve_omega, dragon_curve_expansion_rules, 90, 10)
dragon_curve.print_pattern()

generated dragon curve

References

About

A class to draw curves expressed as L-System production rules

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages