Totally Objects Home Page Turtle Graphics

What's New? Products Totally Objects Downloads Other Downloads Consultancy VAST Training
Educational Discounts See what our clients think Buy News Groups Consultant's Pack Contact Us

VisibilityTurtle is a new class that has been added to Visibility to provide an interface into Turtle Graphics.

There are three categories of public methods in the class comprising of:

Public Categories

VisTurtleCommands The commands that make the turtle do things
VisTurtleDirectionCommands The commands that make the turtle move
VisTurtleSettings The commands that change the turtle's state

Visibility Turtle Direction Commands

Click here for a full list of direction commands

These commands tell the turtle where to go. There are two forms:

  1. Answers a new location or the distance to a new location
  2. Sets the new location

Thus there are two commands - right and toRight. The method right answers the x location of the right hand side of the current page. The method toRight tells the turtle to move to that same location (drawing a line or not depending upon the pen settings). Not all commands are in pairs - for instance, there is no need for a movement command for the current location - the turtle is already there - but there is a method that answers the current location.

There are two further sub-categories:

  1. Movement commands based upon the current distance measurements - for example in mm.
  2. Movement commands based upon font heights to enable text to be placed correctly in lines down the page.

Distance commands

There are two types of distance commands:

For a full list of these methods, click here. For a flavour, this is an excerpt:

bottom Answers the  bottom of  the drawable area on the current page. Informative type
toBottom Sets and answers the current Turtle location to the bottom of the drawable area on the current page. Setting type


These tell you where the required location is, so sending the command topCenter to the turtle will result in a point which gives the center location of the top of the page, which on an A4 page of 210mm wide would be 105 @ 0. Likewise, center would give 105 @ 148.5.


These all have the form toXXX (don't confuse with topCenter - the use of top in some informative commands is a trifle confusing but was unavoidable). Thus, sending the command toTopCenter will relocate the turtle position at 105 @ 0 (to use the above example). The turtle will retain its existing heading.

 Font based commands

These will be covered in slightly more detail so that the background and need is fully explained.

Each and every font has an associated height. To move the turtle correctly down exactly one line means knowing that distance and converting it to the correct units. In addition, there is a small amount of space - called leading - that is needed between the lines so that there is sufficient space for each line to be read comfortably. These turtle commands provide that information for both the current font and any other font defined in the system.

Note re: Fonts - all fonts used by the turtle are those defined in the standard Visibility font dictionary held as a class method of VisibilityPrinter - fontArray.

The basic information used is the height of one line for any given font - lineheight: aFont - this command provides the basic information for any font. aFont is a string which corresponds to a font in VisibilityPrinter fontArray. From there, the turtle has a series of commands similar to move: aDistance and moveTo: aLocation. These take two forms.


These are all instructions to the turtle to carry out relative moves from the current location, thus linesUp: 5 tells the turtle to move up the distance required for 5 lines of text in the current font. linesUp: 5 forFont: aFont tells the turtle to move up the distance required for 5 lines of text in the chosen font. linesDown: operates in the same way but moves the turtle down towards the bottom of the page.


These are instructions to the turtle to carry out absolute moves, thus toLine: 5 tells the turtle to move to the 5th line down from the top, using the current font height.

Sample code

turtle toTopLeft;        "moves the turtle to the to left hand corner"
        toLineDown;      "moves the turtle one line down"
        penDown.           "ok to draw a line"
1 to: 10 do:[: i | turtle toRight; penUp; toLineDown; toLeft; penDown].    "draws 10 lines across the page using the correct font height + leading for the current font."

Back to Totally Objects Home Page