GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - antigones/LSystems: A class to draw curves expressed as L-System production rules

BranchesTags
Open more actions menu

Latest commit

 

History

26 Commits
26 Commits

Folders and files

NameName
Last commit message
Last commit date
imgs
imgs
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
lsystem.py
lsystem.py
 
 
lsystem_examples.py
lsystem_examples.py
 
 
parametric_lsystem.py
parametric_lsystem.py
 
 
parametric_lsystem_examples.py
parametric_lsystem_examples.py
 
 
renderer.py
renderer.py
 
 

Repository files navigation

L-System

A class to expand strings with L-System production rules and render them with Turtle.

from lsystem import LSystem
from renderer import render_pattern
import turtle

koch_omega = "F"
koch_expansion_rules = {
    "F": "F+F-F-F+F",
    "+": "+",
    "-": "-"
}

koch = LSystem(koch_omega, koch_expansion_rules)
pattern = koch.expand(times=3)

koch_instructions = {
    "F": lambda: turtle.forward(10),
    "+": lambda: turtle.left(90),
    "-": lambda: turtle.right(90),
}

render_pattern(pattern, koch_instructions, line_thickness=2)
  • omega: the axiom
  • expansion_rules: the set of expansion rules
  • expand(times): generate the pattern after the specified number of iterations

koch curve

Usage example

dragon_curve_omega = "F"
dragon_curve_expansion_rules = {
  "F": "F+G",
  "G": "F-G",
  "+": "+",
  "-": "-"
}
dragon_curve = LSystem(dragon_curve_omega, dragon_curve_expansion_rules)
dragon_curve_pattern = dragon_curve.expand(times=10)

dragon_curve_instructions = {
  "F": lambda: turtle.forward(10),
  "G": lambda: turtle.forward(10),
  "+": lambda: turtle.left(90),
  "-": lambda: turtle.right(90),
}
render_pattern(dragon_curve_pattern, dragon_curve_instructions, line_thickness=2)

generated dragon curve

References

  • https://www.wikiwand.com/en/L-system
  • https://en.wikipedia.org/wiki/L-system

About

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

Topics

fractalsmathspace-filling-curves

Resources

Readme
Activity

Stars

7 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.