     LSYSTEM(1)                                                       LSYSTEM(1)

     NAME
          lsystem - L system fractal generator

     SYNOPSIS
          lsystem [options] [file]

     DESCRIPTION
          lsystem is a fractal generator is based on the scheme devised by
          Aristid Lindenmayer (the L in Lsystem).  It is a so-called string-
          rewriting system, in which an input string is altered according to a
          set of transform rules.  The characters that make up the string, in
          turn, can represent commands to a "turtle" which will draw the actual
          fractal.  More sophisticated Lsystem incarnations have been used to
          create very lifelike renderings of plants (see "The Algorithmic Beauty
          of Plants", written by Prusinkiewicz and Lindenmayer, published by
          Springer Verlag).

          Here's an example of a string-rewriting system.  Consider the initial
          condition: b And the rules are: a = ab b = a Here are the results of 5
          passes through the string-rewriting engine: b (initial) a ab aba abaab
          abaababa If "a" and "b" represented commands to a turtle-like drawing
          routine, the output string "abaababa" could be fed to it, and it would
          generate some type of figure.

     OPTIONS
          -o file
                  Write output to file.

          -s      Print string length info.

          -v      Print version info.

     OPERATION
          lsystem reads an L system description from the specified file and
          writes drawing commands on the standard output (or a file, if
          specified with the -o option).  These drawing commands should be piped
          through to convert them to the graphics driver of your choice.

          The drawing commands are generated in two phases: the string-rewriting
          phase, in which the initial string is iterated using a set of rules,
          and the string-interpretation phase, where the iterated string is
          passed to a `turtle' which substitutes macro definitions and executes
          drawing commands.

     INPUT FORMAT
          The input to lsystem consists of an initialization statement and
          several statements defining macros and rules.  Blank lines are
          ignored, and anything from a # to end-of-line is a comment.  The
          initialization statement has the format init <string> <iterations>
          <angle> where <string> is the initial string to be iterated,
          <iterations> is the number of iterations to perform, and <angle> is

                                        - 1 -       Formatted:  October 24, 2000

     LSYSTEM(1)                                                       LSYSTEM(1)

          the angle through which the turtle turns when given the appropriate
          command.  Strings in lsystem may consist of the letters A-Z (upper or
          lower case), +, -, [ and ].  Several of these have special meanings to
          the turtle, described later.

     MACROS
          Macros are useful to help simplify the design of fractals.  They are
          only used during the string-interpretation phase, when the turtle is
          in operation.  The format for defining a macro is <char> = <string>
          When the turtle is drawing, each occurrence of <char> is replaced
          (once only) by <string>.

     RULES
          Rules specify what replacements are done in the string in the
          iteration phase.  In each iteration, rules are applied to the string
          in the order they were defined in the input.  The format of a rule
          definition is <char> -> <string> Each instance of <char> in the string
          is replaced by <string>.

     TURTLE COMMANDS
          The turtle understands a limited set of commands.  If it encounters a
          foreign character, it simply ignores it.  This can be useful for
          building up complex strings.

          F       Move turtle forward one step.  A line is drawn.

          f       Move turtle forward one step.  No line is drawn.

          +       Turn turtle clockwise by the angle increment.

          -       Turn turtle anticlockwise by the angle increment.

          [       Stack turtle state.  This includes position, heading and
                  current colour (see COLOURS, below).

          ]       Unstack turtle state.  The state is restored to the matching
                  [.  No line is drawn if the turtle position changes.

     COLOURS
          You can change the colour of parts of the drawing (on those graphics
          devices which support colour) by setting characters to different
          colour values.  In the string-interpretation phase, when the turtle
          sees a character, the current colour is set to its corresponding
          colour.  If the character has no colour, no colour change is done.
          The format of a colour command is col <char> <red> <green> <blue> This
          sets <char> to have the specified RGB values.  The RGB values are in
          the range [0-1].

     RESTRICTIONS
          Complex rules and/or high iteration factors will take awhile to run
          through the lsystem engine.  The string may become larger than

                                        - 2 -       Formatted:  October 24, 2000

     LSYSTEM(1)                                                       LSYSTEM(1)

          available memory, too.  Each pass through the lsystem engine can
          produce an exponential increment in the length of the string, so ANY
          amount of memory will be filled.

     FILES
          %%LIBDIR%%   Example L systems

     HISTORY
          This implementation of L systems is based on (and uses the same
          examples from) an Atari ST version written by Mark Kimball (1991).

     SEE ALSO
     AUTHOR
          Glenn Hutchings (zondo@hunting2.demon.co.uk)

                                        - 3 -       Formatted:  October 24, 2000