Back to Program Lgrammar
About Lgrammar
Help for Lgrammar
Index
LGrammar implements a two-dimensional and a three-dimensional graphics
tool for evaluating Lindenmayer grammars. These grammars are characterized
by having no terminal symbols and by performing all possible symbol
replacements in parallel for each step.
- F forward with line drawing Turtle moves in direction of its
orientation vector (head) for a fixed distance and draws a line
- f forward without line drawing Turtle moves in
direction of its
orientation vector (head) for a fixed distance without drawing
- + Turtle turns left by a specified angle
- - Turtle turns right by a specified angle
- [ start branching Push current turtle position and orientation
on stack
- ] terminate branching Pop data from stack replacing
current turtle position and orientation
- | flip Turn turtle about 180 degree
- ' Increment color index
- ` Decrement color index
- F forward with line drawing . Turtle moves in direction of its
orientation vector (head) for a fixed distance and draws a line.
Has no effect within a polygon '{ }' (see G)
- f forward without line drawing . Turtle moves in direction of its
orientation vector (head) for a fixed distance without drawing
New position is recorded as a corner point within polygons '{ }'.
- + Turn turtle about axis 'up' by a specified angle
- - Turn turtle about axis 'up' by the negative of a specified
angle
- & Turn turtle about axis 'left' by a specified angle
- ^ Turn turtle about axis 'left' by the negative of a specified
angle
- \ Turn turtle about axis 'head' by a specified angle
- / Turn turtle about axis 'head' by a specified angle
- | Turn turtle about axis 'up' by 180 degrees
- [ start branching Push current turtle position and
orientation on stack
- ] terminate branching Pop data from stack replacing
current turtle position and orientation
- { start polygon render a polygon, e.g. for a leaf
- } terminate polygon
- . Define a corner point within a polygon '{ }'
- G Corresponds to F within a polygon '{ }'
- ' Increment color index
- ` Decrement color index
- first line: enter the axiom (a sequence of turtle symbols),
terminated by Return
- further line:
enter the production rules with the following form
left side "=" right side
with
- left side equals one turtle symbol
- right side equals several turtle symbols
for example:
axiom: F-F-F-F
rule: F=F-F+F+F-F
axiom
after the second derivative
- Accept the new grammar by pressing the Init button.
Press the Next button to generate the next grammar derivative.
With the Single button you can derive only the next symbol.
Pressing the Next button will complete this derivative.
- Any characters may be used as grammar symbols. Characters which do
NOT have a predefined graphics meaning (e.g. F does, but E does not)
are used for grammar derivation, but will not generate graphics
themselves. Further on you can use indice to differ between differnt
handlings, for example F<a> will draw a line too.
- The values for Length and Angle apply to all "F", "+",
"-", and so on in a grammar. In order to have different length or angle values
for individual symbols, these values may be specified after the
symbol in sharp brackets, e.g.
- +<45> denotes turning left by 45 degrees, no matter what the global
value for Angle is
- F<500> denotes drawing a line of length 500, no matter what the
global value for Length is
If you click the Color button in the applet threre'll appear a window with 2 color palettes.
In the first one you can choose between the 3 standard palettes
- Default - a rainbow colored palette
- Green - mainly green and brown colors
- Grey - grey colors
by pressing the according button.
The second palette is for creating your own color order. Click at any field in the first
palette and once again at any in the second one to copy a color. To tell the
system that it should draw with the second palette, click the accept button.
The '#' symbol at the according label indicates the current color palette.
Using individual values as probabilities for a rule after the equal sign
results in defining stochastic grammers. Here, is it allowed to have
several rules for the same symbol, however, the sum of all probability
values for this symbol has to be 1, e.g.:
If you press the Load button, you can choose between several examples.
Just add the according filename at the and of the indicated URL in the
button textfield, maybe you can use the copy and paste mechanism of your
system.
Confirm this by clicking the ok button.
Because of security restriction of java/netscape it's only possible to save
your own grammars in the interpreted version.
- Do not to terminate the input grammar with return.
- To refresh the graphtal, click on the Refresh Button and the
program will draw the graphic once again.
P. Prusinkiewicz, A. Lindenmayer:
The SAlgorithmic Beauty of Plants
Springer-Verlag, New York, 1990
Chr. Drabek (in German)
Implementierung von L-Grammatiken zur Erzeugung von Graftalen
Diplomarbeit no. 986, Univ. Stuttgart, Fakultaet Informatik, 1993
Back to Program Lgrammar
About Lgrammar