Oberon || Library || Module Index || Search Engine || Definition || Module

Ulm's Oberon Library:


TurtleGraphics - subset of turtle graphic operations for plotters


TYPE Graphic = POINTER TO GraphicRec;
TYPE GraphicRec = RECORD (Services.ObjectRec) END;

PROCEDURE Create(VAR graphic: Graphic; angle: REAL);

PROCEDURE EnableRoundCorners(graphic: Graphic; cornerFraction: REAL);

PROCEDURE PenDown(graphic: Graphic); PROCEDURE PenUp(graphic: Graphic);

PROCEDURE Save(graphic: Graphic); PROCEDURE Restore(graphic: Graphic);

PROCEDURE Left(graphic: Graphic); PROCEDURE Right(graphic: Graphic); PROCEDURE Forward(graphic: Graphic);

PROCEDURE ApplySymbols(graphic: Graphic; symbols: ARRAY OF CHAR);

PROCEDURE Plot(graphic: Graphic; plotter: Plotters.Plotter);


Turtle graphics were invented for the Logo programming language which was developed 1967 at MIT by Seymour Papert, Wallace Feurzeig, and others. A turtle graphic maintains a state consisting of a position on a 2-dimensional plane, a direction, and a pen position. All operations work relative to the current position and the current direction.

Create creates a new turtle graphic system. Turns (be it left oder right) operate with a fixed angle which is to be given in degrees. Traditional turtle graphics use an angle of 90 degrees.

EnableRoundCorners requests tangential arcs to be used for the corners. The fraction out of the range (0,0.5) specifies the part of a unit line which may be used for it. This is, for example, helpful for Dragon curves which would otherwise self-intersect. Round corners are not used at branch positions (generated by Save and Restore).

PenDown causes future forward moves to be drawn. Initially, the pen is already down. PenUp causes following forward moves not to be drawn until PenDown is called.

Save saves the current state (current position, current direction, and pen position) for later restoral by Restore. Restore restores the previously saved state. Save and Restore can be arbitrarily nested.

Left turns the current direction to the left by the angle that was given to Create. Right turns the current direction to the right.

Forward moves forward one unit and causes, if the pen position is down, a line to be drawn.

ApplySymbols draws a string of Lindenmayer symbols from which following are supported:

PenDown, Forward
PenUp, Forward

All other symbols are silently ignored.

Plot draws the turtle graphic graphic on plotter with a scale that is automatically adapted to the plot area.


Assertions verify that the corner fraction of EnableRoundCorners is within the range (0,0.5) and that Save and Restore are properly balanced. No error events are generated.


general plotter interface
Przemyslaw Prusinkiewicz, Aristid Lindenmayer, ``The Algorithmic Beauty of Plants'', Springer-Verlag
Edited by: borchert, last change: 2004/04/08, revision: 1.3, converted to HTML: 2004/04/08

Oberon || Library || Module Index || Search Engine || Definition || Module