# The L-System Editor

As always, this documention assumes some general familiarity with L-systems and only describes JFLAP's implementation of these structures. JFLAP allows a user to define an L-system and to render that system with an arbitrary level of substitution in three dimensions. The formal definition of an L-system requires three components, to which we add one to aid in drawing:

System alphabet
  JFLAP does not require the user to explicityly set the alphabet (i.e. set of recognized symbols) of the system. If a symbol is does not have significance to whatever is attempting to interpret it is ignored, e.g. a renderer of an L-system would be interested in those symbols that affect the rendering and those symbols which have replacement rules.

  While the rules of replacement, the presence of an axiom, and soforth are universal to L-systems, the interpretation of those symbols to render a graphic is not part of the mathematical definition. At present there is one L-system renderer in JFLAP, and its description, including the symbols it recognizes, may be found here.

Axiom
  At the top of the editing view is a text field for typing in the axiom labeled, appropriately enough, "axiom." As mentioned before symbols are space delimited. In the example given above, the three symbols in the axiom are +, g, and L, in that order.

Rewriting Rules
  Below the axiom is a series of productions that represent the replacement rules; one enters these just as one would enter productions for a grammar. As with the axiom, symbols must be space delimited. In most cases you will want only one symbol on the left. The two rewriting rules in the example picture are L L + R g + and R - g L - R, that is, going from one level of substitution to the subsequent level of substitution, every L shall be replaced with the five symbols L + R g +, and every R shall be replaced with the five symbols - g L - R.

  You can also have multiple symbols on the left side of the rewriting rule. JFLAP offers rules that are sensitive to context. These rules take the form of i a0 a1 ... ai-1 ai ai+1 ... an-2 an-1. In this list of n+1 symbols, the i symbol is an integer from 0 inclusive to n exclusive; the symbol ai is the symbol potentially being rewritten, but only if the string of symbols a0 a1 ... ai-1 come before it and ai+1 ... an-2 an-1 come after it. For example, the rewriting rule 2 a b c d x y z, in an expansion c would be rewritten with x y z if preceeded by the two symbols a b and the symbol d.

  If multiple replacement rules dictate that a symbol is to be rewritten, one of the rules will be chosen uniformly at random when the expansion of symbols occurs. Additionally, lambda productions are allowed and indicate simply that the symbol should be removed.

Drawing Parameters
  Below the grammar input, and at the bottom of the window, there is a table the user may set parameters that affect the rendering of the L-system. The user enters the parameter name in the left column, and its value in the right column. In the example L-system input figure, we have the two parameters named angleIncrement and distance, with values 90 and 4 respectively. Mind you, these parameter names are case sensitive! If the same parameter is defined multiple times in the table, only the last definition of the parameter is respected.

  Above the right scroll bar, just to the right of the "Parameter" column label, there is a small button. If you press it, you will see a popup menu with a list of those parameters the L-system renderer in JFLAP recognizes (one can't remember them all, can we?). For a full description of these parameters, view the pages for the L-system Renderer When you select a parameter name from this list, it will be entered into the table, and you will begin editing the value for that parameter. If you select a parameter that already exists in the table, then you will begin editing the parameter value for the existing entry.

## In Haiku

The axiom field
holds the starting point
of the L-system.

The middle table
displays the rewriting rules.
You edit them here!

Rewriting rules look
like a grammar production
with left and right sides.

A rule's left side holds
the symbol to replace in
derivation strings.

The right side contains
what symbols the left symbol
will be replaced with.

The strings of symbols
in JFLAP's L-systems are
space delimited.

Strings without whitespace
should therefore be considered
a single symbol.

That is important!
Don't mistake "gfgg"
for "g f g g"!

The bottom table
holds drawing parameters
for the L-system.

Parameters set
in this table change how the
L-system renders.

The left column "Name"
holds the parameter name.
Right holds the value.

As an example,
set "color" to the value "green"
and "g" draws green lines!

Also, consider
setting "distance" to "18".
Lines are that length now.

You click in the box
above the table's scroll bar
for a list of names.

Choose one of these names,
and that named parameter
shows in the table.

Want to render this?
You choose the menu item
named "Render System"