|
Turtle Graphics
Turtle Graphics is a great way to begin learning to program but may also be used to learn some kinds of mathematics (such as trigonometry) or otherwise experiment with basic drawing graphics. Turtle Graphics has a long history in computer science, dating from the early days of programming languages that could create a graphical display on screen (not only text mode). The name Turtle Graphics refers to the fact that originally the current location of the drawing 'pen' on the screen was represented by a symbol resembling a turtle. This 'turtle' could be instructed to move around the screen and would leave a trail (line) behind it as it moved. In TJI, no turtle is shown, but the basic principle is the same. In TJI, Turtle Graphics projects are GUI applications. Most TG projects can be written in a single class that extends class TurtleFrame in package com.kinabaloo.turtle The classes in this package are included in ide.jar There is no need to extract these classes from ide.jar - they will be found automatically; you simply need to import package com.kinabaloo.turtle in the child class that extends class TurtleFrame. Having extended class TurtleFrame, you can create objects of class Turtle using method Turtle createTurtle(). You can create as many turtles as you like. The Turtle class provides many methods for guiding the turtle around the screen and defining how and when it draws a line trail behind it. A basic Turtle Graphics project will consist of a single class like this :
The method public void run() is defined in class TurtleFrame and designed to be overrided by the child class. This method is called when the 'Run' button of the Turtle Frame GUI is clicked. The best way to learn how to create your own Turtle Graphics projects is to look at the example TG projects available for download from TJI's web site ('Resources' page). There are 10 example projects illustrating a number of the many possible uses. You can also refer to the API documentation below.
JavaDoc API Documentation
|