RedLTurtle:
Filter:
redUniverse/Classes (extension) | Red > redUniverse > additional

RedLTurtle
ExtensionExtension

turtle graphics for RedLSystem

Description

Plotting with Pen. After Flake - "The Computational Beauty of Nature".

Class Methods

.new

Arguments:

lsystem

An instance of RedLSystem or a String.

length

Line segment length in pixels.

theta

Angle in degrees.

scale

The amount to scale all moving commands ($F, $G, $|) in percent.

noise

The amount of uniform noise to add to all angles in radians.

Instance Methods

.draw

Start drawing the l-system or string at current Pen position.

.defaultCommands

Return a dictionary of default (character : function) pairs.

$Fdraw forward
$Ggo forward
$+turn right by theta
$-turn left by theta
$[push state
$]pop state
$|draw forward scaled by depth

An Integer before each character repeats that command n times.

.addCommand

Make up new rules by putting a character : function pair into command dictionary. Arguments passed in to function: depth, depthLength, index.

.makeWindow

Creates a Window and draw the l-system or string. Mainly for testing.

Arguments:

bounds

A Rect.

initAngle

Sets the initial Pen rotation in radians.

initTranslate

Sets the initial Pen translation in percent.

.lsystem

Either a RedLSystem or a String. For strings depth and thereby $| scaling is ignored. For l-systems (the preferred way) the depth is calculated ($| scaling by generation).

.length

.theta

.scale

.noise

.commands

A dictionary of current commands.

.preCommandAction

A general Function that gets evaluated right before each command (character in the production array). Arguments passed in to function: depth, depthLength, index.

Examples