2.0 The Graphics Canvas: Turtle and Coordinates
2.0 The Graphics Canvas: Turtle and Coordinates
Logo’s graphics model is strategically centered on a simple yet powerful concept: the Turtle. All visual output is mediated through this programmable cursor, whose state—including its position, heading, and pen status—is directly controlled by programmer commands. Mastering the management of the Turtle’s state is the essential skill required to create any graphical output, from simple geometric shapes to complex, recursive patterns. This section details the Turtle’s state management commands, which are used to position the Turtle precisely before using pen commands to begin drawing.
2.1 The Turtle Primitive
The Turtle is the central entity on the drawing canvas. It appears as a small triangle and acts as a robotic cursor that responds to a specific set of commands. All drawing operations are executed relative to the Turtle’s current position and orientation, making it the focal point for all graphical programming in Logo.
2.2 Canvas Coordinate System
The graphics window operates on a two-axis Cartesian coordinate system, with X and Y axes. The key properties of this system are:
- Origin: The center of the canvas is at coordinate 0 0.
- Boundaries: The corners of the visible canvas have the following coordinates:
- Northeast: 250, 250
- Southeast: 250, -250
- Southwest: -250, -250
- Wrap-Around Behavior: If the Turtle is commanded to move beyond an edge of the screen, it does not stop but “wraps around” to the opposite edge. For example, moving off the right side causes it to reappear on the left, and moving off the top causes it to reappear at the bottom.
2.3 Turtle State Management: Position and Heading
The Turtle’s state can be explicitly set or queried at any time. Its heading is based on a compass rose model, where 0 degrees is straight up (north), 90 degrees is to the right (east), and so on. The following commands provide direct control over the Turtle’s position and orientation on the canvas.
| Command Syntax | Purpose |
| setx [value] | Sets the turtle’s x-coordinate. |
| sety [value] | Sets the turtle’s y-coordinate. |
| setxy [x] [y] | Moves the turtle to the specified xy coordinate, possibly leaving ink while reaching these coordinates. |
| setheading [degrees] or seth [degrees] | Points the turtle to the specified absolute heading (0-360). |
| show xcor | Reports the turtle’s current x-coordinate. |
| show ycor | Reports the turtle’s current y-coordinate. |