Lystem is cross platform command line application to render L-System interpreted as turtle instructins. The program renders a series of images, one for each instruction (or more). It does not directly make a video, for that you can use something like ffmpeg with:
ffmpeg -r 60 -i images/out%d.png output.mp4
The LSystem generator is made to occupy as little memory as possible, so it can run on limited devices too.
Contributions are welcome and at the start of src/main.rs you can find a TODO list.
You can build the project with cargo
cargo run --release -- [ARGS]
There are two required parameters, the input configuration, and the number of generations to simulate
cargo run --release -- configs/maze.yml 3
This will render the images of the 3rd generation of maze.yml, interpreted by the turtle as specified in the file.
Optional parameters are:
-lwhich sets the program to only render the last frame (when all the turtle instruction have been executed)-swhich sets how many turtle instructions should be executed in each frame (translates to the playback speed, there more instruction you interpret per frame, the faster the video will be)
The L-System axiom and rules, along with the instructions to interpret the characters as turtle commands are written in yaml files. You can find many examples in the configs directory.
axiom: F+F+F+F
start_state:
'color_r': 255
'color_b': 255
'step': 1
'turning_angle': 90
rules:
'F': FF+F+F+F+FF
commands:
'F':
- forward
- add color_r -1
'+':
- clockwise-
axiomindicates the system axiom, each character is interpreted as a single symbol, only ASCII character are supported -
start_statedescribes the turtle initial state, there are many variables accessible:color_r,color_g,color_bto indicate the r,g,b values of the turtle drawing color, from 0 to 255stepwhich sets how far the turtle travels each time it goes forwardturning_angleturning angle of the turle used by theclockwiseandcounterclockwisecommandsrotationthe initial rotation of the turtle
-
rulestells how each symbol evolves -
commandssays how to interpret the symbol as a turtle commandforwardmakes the turtle go foward bystepclockwise/counterclockwisemakes the turtle turn clockwise/counterclockwise byturning_anglepush_stackpushed the current turtle state on the stackpop_stackpops the stack on the current turtle stateadd/multiply/setare functions which take two arguments, the variable to change and the value to apply. A variable can also be used as a value:add turning_angle stepadds the value of step to the turning_angle. An integer can also handle operations with a decimal number (multiply color_r 1.5), being rounded toward -infinity after the calculations.



