Generate and draw L-systems
app | ||
img | ||
src | ||
test | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
package.yaml | ||
README.org | ||
Setup.hs | ||
stack.yaml |
L-Systems
https://travis-ci.org/dlozeve/lsystems.svg?branch=master
Generate and draw L-systems!
Introduction
This program can be used to generate arbitrary L-systems. It supports:
- full rewriting rules
- full representation rules
- personalized angle and segment length for the representation
- push ('[') and pop (']') operations
LSystem
data type
An L-system consists of:
-
the L-system itself:
- an alphabet
- an axiom (i.e. the starting point)
- a set of rewriting rules (represented as a list of tuples)
-
rules to transform it into a graphical representation:
- an angle and a length
- a set of representation rules (which symbols mean "draw forward", "turn left", "pop a position", etc.)
Building and running
You will need Stack.
From the repository, run:
stack build
stack exec lsystems-exe
This will open a window, where you can move around using the mouse and zoom by scrolling.
For tests and documentation, run:
stack test --haddock
Examples provided
Space-filling curves
Fractals
- Lévy C curve
- Koch snowflake and Koch curve
- Sierpinski triangle and Sierpinski arrow curve
- Dragon curve
- Binary tree and fractal plant
Tilings
Implementation
The program is implemented in Haskell, using Gloss to display the generated L-systems.