L-Sys/JS Help

Lindenmayer-Systems (L-Systems) are described using simple grammars. A L-System consists of an axiom, rules, constants and symbols. The rules are first applied to the axiom and then to the resulting output for each iteration.

Turtle Commands

In LSys/JS L-Systems are visualized using a virtual turtle moving around on the drawing area. The turtle is controlled using commands made up from single characters. The following table gives an overview of all commands supported by LSys/JS.

+ Turn left by angle δ
Turn right by angle δ
[ Save the current position of the turtle on the stack. Starts a new branch.
] Retrieve the last saved position of the turtle from the stack. Completes and terminates the current branch.
A-Z Move forward drawing a line segment. By default all uppercase characters make the turtle move forward and draw a line. Using rules this behaviour can be changed.
a-z Move forward without drawing a line. By default all lowercase characters make the turtle move forward without drawing a line. This behaviour can be changed by defining a rule.

Syntax

The following list shows all known expressions to describe an L-System. The number of rules is only limited by the available characters. Thus a maximum of 52 rules can be defined - 26 for uppercase characters and 26 for lowercase characters.

Parameters

iterations=<INTEGER> Sets the number of iterations (Default value: 1)
angle=<FLOAT> Sets the angle δ (Default value: 90)
length=<INTEGER> Sets the line length s (Default value: 10)

Axiom and Rules

axiom=<COMMANDS> Sets the axiom to <COMMANDS>
<CHARACTER>:=<COMMANDS> Defines a new rule for <CHARACTER>

Other

#<COMMENT> All lines beginning with a number sign are ignored and can be used to make comments.

Example

The following example shows how to use all of the above described expressions.

# tree 1, Philipp Stucki
# Draws a tree like structure

iterations=4
angle=27
length=8

axiom=AX
A:=AB
X:=F[-Z]F[+X]F[-Z]+X
Z:=-D[+X]DD[-X]+X
F:=FF

User Interface