This is a little program to generate curves using primitive L-systems - err, well, to draw neat pictures using simple rules. You can specify your own L-Systems by passing them to L at the command prompt, or you can just look at some of the examples already built into the program.
Running L without arguments
$ ./L will run the program. Click the left mouse button to increase the level of recursion and redraw the image. Hold down shift to decrease the level of recursion. Pressing 'q' quits the program, and pressing 'n' will load a different set of rules, giving you a new image to play with (the level of recursion will be set back to zero).
Running L with arguments
You can pass your own L system as arguments to L from the command prompt. The form is
$ ./L <level> <rule> <angle> <length> <shrink> <initAngle> <sides>
where the arguments stand for the following (taken from the comments in the source file):
- The LEVEL specifies the starting level of recursion when you start the program.
- The RULE is a string of characters where:
- 'F' indicates "Move forward"
- '+' indicates "Turn right"
- '-' indicates "Turn left"
Other variables (eg. 'X' or 'Y') and branching (eg. brackets '[' and ']') are not supported.
- The ANGLE specifies how much to turn, and
- the LENGTH specifies how far to move.
- The SHRINK factor specifies how much lengths have to be scaled down when iterating recursively.
- The INITANGLE specifies the initial orientation of our walking turtle.
- The SIDES parameter allows you to display your curve n-times as the edges of an n-sided polygon, where n is SIDES
Example: To create a Koch snowflake, you would enter ./L 0 "F-F++F-F" 60.0 1.0 3.0 60.0 3.0
How to define your own curves (also taken from L.c)
Pick a rule. eg: F-F++F-F could define a Koch curve. In this case, you'll need to
set the turning angle to 60.0 degrees. Pick some length for each segment, say 1.0.
Now to decide on the strech factor. Draw out the path resulting from a single application of
this rule. Then measure the distance from begining to end. For example (hope you have fixed-width fonts enabled!)
/\
/ \
/ \
/ \
/ \
--------- ---------
|- 1.0 --|- 1.0 --|- 1.0 --| sums to 3.0 for our curve.
So the stretch factor is 3.0, that is, we have to scale the curve down by a factor of 3.0
to fit a new copy of itself on each edge. It's important that you orient your drawing such
that the start and end points of this "curve" are at the same height. I'm working on a way
to allow curves that do not have this restraint, but you can still get around this problem.
For example, the terDragon curve orginally looked like this:
----------
\
\
\
\
\
\
\
\
\
________\
So I rotated it until it satisfied the restraint that the starting and ending points had the same
vertical component. Note that this can be done with many curves - it just requires one to work out
the necessary changes to the angles and shrink factor. Ideally L would calculate all this for you and you wouldn't have to specify a shrink factor - I just never got around to it....
Decide upon an orientation for your curve. If you want it to point upward, for example,
pick 90 degrees.
Oh, by the way, if you'd like to recompile the program, just type make L.
The source code is commented (even I can't believe it!), so it probably contains more info than this README.
Have fun!
Examples

+F----F++++F-

F-F+F+F+F-F-F-F+F

F-F++F-F (3 sides)

F-F+F+FF-F-F+F

+F--F+

+F--F+ (3 sides)
|
|