L-System Language

Home • Gallery • Tutorials • Download • Purchase • Site Map
 

L-System Language Syntax

Skip this page if you are not a programmer.

The L-System language is used to produce L-System Fractals. The L-System language supported by the Fractal Science Kit fractal generator is adopted from the Fractint syntax described in the Fractint L-System Documentation and the Fractint L-Systems Tutorial by William McWorter. There are many example L-System files available on the Internet (see below).

The following is a brief description of the syntax. Please see the above references for detailed information.


An L-System program has the following syntax:

<TITLE> {
  <INSTRUCTIONS>
}

<TITLE> is the name of the L-System and <INSTRUCTIONS> are L-System statements.

The different L-System statements are given by:

 Angle={COUNT} : set angle used by '+' and '-' below to 360/{COUNT}
 Angle {COUNT} : set angle used by '+' and '-' below to 360/{COUNT}
 
 Axiom={COMMANDS} : set starting set of commands to {COMMANDS}
 Axiom {COMMANDS} : set starting set of commands to {COMMANDS}

 {COUNT}+  : turn left {COUNT} times. if {COUNT} is omitted, use 1
 {COUNT}-  : turn right {COUNT} times. if {COUNT} is omitted, use 1

 |         : turn 180 degrees or the largest possible turn < 180 degrees

 f         : draw a line using the current direction/length
 g         : move forward instead of drawing

 \{ANGLE}  : turn left {ANGLE} degrees
 /{ANGLE}  : turn right {ANGLE} degrees

 d         : draw a line using the current direction/length
 m         : move forward instead of drawing

 [         : save state (position, angle, size, etc.)
 ]         : restore state

 !         : reverse the meaning of '+' and '-' and '\' and '/'

 @{SCALE}  : multiply the current line length by {SCALE}
 @q{SCALE} : multiply the line length by the square root of {SCALE}
 @I{SCALE} : multiply the line length by the reciprocal of {SCALE}

 c{INDEX}  : set color map index to {INDEX}

 <{COUNT}  : increment color map index by {COUNT}
 >{COUNT}  : decrement color map index by {COUNT}

 {LETTER}={COMMANDS} : associate {COMMANDS} with character {LETTER}

Please note the following:

  • Character case is ignored so F is the same as f.

  • In any given L-System program you should use either the relative commands (+, -, f, g) or the absolute commands (\, /, d, m), but not both. The | command applies only to angle associated with the relative commands.

  • Spaces may be used between commands but not between commands and their arguments.

  • All text to the right of a semi-colon (;) character is ignored and can be used to comment code.

  • Do not use { or } characters within comments as this will confuse the compiler.

Example:

Hilbert { ; The Science of Fractal Images, page 278
  angle 4
  axiom X
  X=-YF+XFX+FY-
  Y=+XF-YFY-FX+
}

The above L-System program generates the Hilbert Curve.


For additional details on L-System fractals see the following:

Eric W. Weisstein. "Lindenmayer System."

From MathWorld--A Wolfram Web Resource.

 

"L-System."

From Wikipedia, the free encyclopedia.

 

Fractint L-System Documentation.

 

Fractint L-System Tutorial by William McWorter.

 

Fractint L-System Space-filling Curves Tutorial by William McWorter.

 

The Science of Fractal Images

M.F. Barnsley, R.L. Devaney, B.B. Mandelbrot, H.-O. Peitgen, D. Saupe, R.F. Voss

with contributions by Y. Fisher, M. McGuire

Appendix C: A unified approach to fractal curves and plants

 


For many L-System examples that can be used with the Fractal Science Kit see:

Fractint L-System Examples.

 

Fractint L-System Tutorial by William McWorter.

 

Fractint L-System Space-filling Curves Tutorial by William McWorter.

 

Charlie Chernohorsky's FractInt@oblivion site.

 

Copyright © 2004-2017 Hilbert, LLC
All rights reserved