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 Settings 

Click here for a full list of settings

These commands are used to define the basic set up and convenience defaults for the turtle.

These fall into two basic categories:

Current and default settings

These have a basic naming convention. They either start with defaultXX or currentXX. The attributes provided are:

This means that each of the above have a pair of commands: currentBox: anExtent and defaultBox: anExtent. If you don't set currentBox then on a call to the currentBox method, the defaultBox setting will be answered. If you have not set the defaultBox then an inbuilt default will be answered. For Box this is set to 0 @ 0. For lineWidth, it is set to 1, and so on. These settings are those used when you do not specifiy a setting. Please note that all of the answer methods are Private as all of these settings are used internally. If you need them, they fall into place automatically.

Example of the use of current and default settings.

If you wish to display a box on the screen then you can just send the drawBox command to the turtle. If you look at the code that implements drawBox, you will see that it instigates a movement up a chain of methods, slowly using various defaults, as follows:

"Draw a box at the current location using the current box defaults."
^ self drawBox: self currentBox

drawBox: aRectangle
"Draw a box at the current location using the aRectangle box extent, the current fill and the current line width."
^ self drawBox: aRectangle fill: self currentFill

The actual drawing is done in drawBox: aRectangle fill: self currentFill.

If you wanted to draw a series of boxes 100 @ 100 at a variety of locations held in an array called boxLocations then you could do the following:

turtle    currentBox: 100 @ 100.
boxLocations do:[ : oneLocation | turtle penUp; moveTo: oneLocation; penDown; drawBox].

This would utilise the current fill, color and lineWidth as well as the currentBox extent. Once you have used the current setting, you can put it back the way it was by sending, for instance, resetBoxDefault to the turtle and the currentBox will now be the defaultBox once again.

Let us say that you wanted to fill each box with a different color, then you would use the following:

color := 1
boxLocations do:[ : oneLocation | turtle penUp; moveTo: oneLocation; penDown; drawBox: 100 @ 100 color: color.
                                                 color := (color + 1) rem: 16].

You can move up the hierarchy as you wish, and even implement other versions, of course.

Other Settings

These change the underlying conditions for the turtle.

Base Measurements

There are three base measurements. 

baseMeasurement: aSymbol. This sets the underlying calculation base to use pixels, inches or millimeters.

baseResolution: aPoint. This sets the underlying pixel resolution. It defaults to 600 @ 600. This would rarely need to be changed. The final output resolution to the screen and printer use these destinations normal settings so changing this is only of use in the location calculations for the turtle.

baseScale: aFloat. This sets the scale that is used to make all location and size calculations. Currently, this is not implemented so all calculations are done using a scale of 1.0. Remember that the final output to the screen can be scaled using other methods in Visibility itself.

Debug Settings

debugToTranscript: aBoolean. If this is set to true, then each action will result in a log trace being sent to the Transcript. Each action has a defined log output so you can track down what is happening during your current turtle run.

debugFile: aPath. If you set a path, then the log output will go to the file named in the path. To avoid overwriting previous log files of the same name, all file names are constructed using your given path, with a string comprising 'HHMMSS.log' appended. Thus, if your path was 'c:\mylogs\test1' then the final file will be 'c:\mylogs\test1170923.log'. You should leave your name without a file suffix.

Page Settings

There are three settings that affect or report on the page itself:

newPrigin: aPoint. This will set the logical origin of the page to aPoint. Thus, to set the origin to the center of the page issue turtle newOrigin: turtle center command. From then on all distances will be calculated with respect to the center of the page.

pageSize: anExtent. This will set the page size to the given extent. This will affect the page as shown on the preview pane but will, of course, not change the printed output as this is def8ined by the paper in the printer.

Back to Totally Objects Home Page