Skip to content

Rackhamn/L-System-One

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

L-System

Also known as Lindenmayersystem.
It is a recursive system built on simple replacement rules.
L-System (Wikipedia)

Current Implementation of Rules

Rules, like F+[FF-X], are handled procedurally and not recursively.
We go through all of the characters in the current state string and apply the current rules.
If the state is FF and the rule is F+F then state+1 would be F+FF+F.

Once we have gone through all of the rules for all of the states for the given number of iterations we can go on to draw the final state onto the image.
As most classic implementation, we also use a "turtle" to draw with. It's just a point in space.
Each rule like F or X draws a line or fills an circle with a color.
Rules like - and + rotates the turtle direction for the drawing.

The program outputs *.ppm images, and they are not viewable online but you should be able to view them on whatever OS you have.

Usage

The run.sh file will build and run the program.
You have to give your basic rules as a string.
./run.sh "F+[FF-]X++[F+FFF]FFFF-FF"
And all of the output is placed into output/*.ppm

Some Select Example Outputs:

More screenshots of the outputs can be found in the img/ directory.

one
four
seven
eleven
fifteen
eighteen
twenty
twentythree
thirty
thirtythree
thirtyfour
thirtyfive
fortysix
fortyone
fortyeight
fivftyfour
Here we can see the basis of the basic L-System rules implemented actually behave when nothing new is happening.
sixtyone
sixtyfive

About

L-System generator in C

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors