L-System

This section will guide you through the creation of an L-System fractal.

 

All the L-System parts are found under the L-System tab:

Now each L-System is made up of some rules, a starting Axiom, a number of Loops, Size and Angle.

The L-System works by a procedure called rewriting. What happens in this rewriting is that the Axiom is expanded using the rules that are available. The expansion is continued for the number of Loops that has been set.

Start Axiom:       F

Rule:                 F=|[-F][+F]
 
Example :
  Iteration 0:   F
  Iteration 1:   |[-F][+F]
  Iteration 2:   |[-|[-F][+F]][+ |[-F][+F]]
  Iteration 3:   |[-|[-|[-F][+F]][+ |[-F][+F]]][+ |[-|[-F][+F]][+ |[-F][+F]]]

As can be seen from the above example the Axiom is expanded using the rule. Thus at each iteration the F symbol will be replaced by the |[-F][+F]. This will continue till the maximum number of iterations has been reached.

 

Now a Quick Look at the Program Functions

By clicking on the Load Button one can load one of the sample L-Systems that are present in the directory LSATF\source\. These are particularly useful if you are still a beginner as they will show you how the parameters should be. When an L-System has been loaded the appropriate values can be seen. To generate the L-System one has to click on the start button.

The start button will start the rewrite procedure. Please note that this can take some time especially on a large number of iterations. One can stop the rewrite procedure by clicking on the Stop Button. The swinging progress bar at the bottom will show activity during rewriting. Once the rewriting procedure has been finished the progress bar will stop fluctuating to and fro and now the L-System fractal can be drawn on screen. To draw the L-System on screen one has to click on the Draw Button or else one can click on the drawing canvas.

Each mouse button has a specific action:
Left Mouse Button Zoom Into the Image and Start Drawing at the current Mouse Coordinates
Right Mouse Button Zoom Out of the Image and Start Drawing at the current Mouse Coordinates
Middle Mouse Button Start Drawing at the current Mouse Coordinates

The magnification factor can be set from the bottom of the window.

 

Other Functions

Colours: There are 3 colour pickers in the display. Two are used for the L-System fractal drawing while the other is the background colour of the drawing canvas. The two colours indicate the first and end colour of the L-System. One must note that some L-Systems can be multicoloured. This is possible if any of the rules contain the '|' character. The colours will shade from the start colour to the end colour automatically.

Clear: This function will clear the drawing canvas, empty the rule list, and clear the start axiom, iterations, angle and size. Basically it restart everything to it's default.

ImageSave: This function will save the fractal image to disk. Once that this option has been selected the following window appears:

You can select the exact region where to save. this can be only portion, the whole fractal. By clicking on a point on the canvas and dragging a rectangle of the shaded region is shown. When the mouse cursor is released the rectangle will show which portion will be save to file. LSATF supports two file formats JPG and GIF and both are useful for a different situation. For an L-System like the one above, to retain the image sharpness a GIF would be better. On the other hand if the image needs to be smoother then a JPG should be used.

Save: The Save Button will save the L-System parameters to an .lsys file. This can then be loaded in the future to generate such a fractal.

 

Rule Syntax

Each symbol in the Rules has a particular action which resolves in drawing. The drawing is done by a turtle like object which starts at a position on the drawing canvas and reads a symbol at a time from the final rewrite string.

Symbol Terminal/Non Terminal Turtle Action
F Non Terminal Move Turtle Forward drawing a line from initial to end position
G Non Terminal Move Turtle Forward
| Terminal Move Turtle Forward with length in respect to iteration number
+ Terminal Rotate Turtle clockwise by Angle
- Terminal Rotate Turtle anticlockwise by Angle
[ Terminal Push Turtle position on stack.
] Terminal Pop Turtle position from stack.

 The + and - symbols can be preceded by a numeric value which indicates the number of turns that the turtle will do. One must also take care that the [ are ] brackets are correctly structured and every open [ must be closed with the ] symbol.