Cheloniidae Turtle Graphics

Cheloniidae Turtle Graphics
Cheloniidae Turtle Graphics
Developer(s) Spencer Tipping
Stable release 3.1 / December 1, 2009
Operating system Linux, Unix, Microsoft Windows, Mac OS, other operating systems with JRE implementations
Type Educational software
License MIT
Website http://spencertipping.com/

Cheloniidae Turtle Graphics is a simple turtle graphics programming library for Java. It is released under the MIT license. Distinguishing characteristics include an extension into three dimensions and the ability to create highly detailed and realistic drawings using colors, solids, antialiased rendering, and incidence angle shading.

Sphere example included with Cheloniidae 2.1

Contents

Architecture

Cheloniidae is broken into two major pieces: The turtle, which executes drawing commands, and the turtle drawing window, which displays the output. Materially, these are analogous to a piece of chalk and a chalkboard, respectively. To create visible output, a turtle drawing window and a turtle must each be created, the turtle must be added to the window (these steps are handled automatically if your class inherits from SingleTurtleScene), and then drawing commands must be issued to the turtle. This code, for example, will produce a square:

 import cheloniidae.*;
 import cheloniidae.frames.*;
 import static cheloniidae.frames.CoreCommands.*;
 public class Square extends SingleTurtleScene {
   public static void main (String[] args) {new Square ();}
   public TurtleCommand commands () {
     return repeat (4, move (100), turn (90));
   }
 }

Internally, a turtle is represented by an object that produces line segments that are rendered by the window. Other types of turtles may also be used, including those which operate in non-Euclidean space; at present, however, no non-Euclidean turtles are included with the standard Cheloniidae distribution.

Multiple turtles can be added as well, allowing for two separate drawings to be produced simultaneously (2.1 code):

Multiple turtle example included with Cheloniidae 2.1
 TurtleDrawingWindow w  = new TurtleDrawingWindow ();
 Turtle t1 = new Turtle ();
 Turtle t2 = new Turtle ();
 w.add (t1);
 w.add (t2);
 w.setVisible (true);
 t2.turn (-45);
 for (int i = 0; i < 4; i++) {
   t1.move (100);
   t1.turn (90);
   t2.move (100);
   t2.turn (90);
 }

Known Bugs

  • If the window is visible and the turtle is still running, closing the window does not terminate the program until the turtle is finished. If the program is being run from the terminal, the user must press Control-C to interrupt execution.

See also

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Gráficas tortuga — Gráfica tortuga es un término usado en computación gráfica como método para programar gráficos vectoriales usando un cursor relativo (la «tortuga») a unas coordenadas cartesianas. Las gráficas tortuga son un elemento clave en el Lenguaje de… …   Wikipedia Español

  • List of reptiles of Ireland — There is only one land reptile species native to Ireland, the viviparous or common lizard. It appears to have a widespread distribution across the entire island with coastal, bogland and mountainous areas showing highest numbers of sightings. A… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”