Graphics Reference
In-Depth Information
Activating the Turtle item in the main menu should enter the user into “turtle graphics” mode,
show a turtle at its current position, and show the menu
A simple drawing of a turtle would be a small square with a line segment emanating from
it to show the direction in which it is looking. Activating “ PolySpi ” in the menu should (start-
ing with the current position and direction of the turtle) draw the path taken by the turtle
according to the following algorithm:
real dist, turnAngle, incr;
integer numSteps;
{Draws numSteps segments of a spiral with given exterior angle
(measured in degrees)}
for i:=1 to numSteps do
begin
Forward (dist);
Right (turnAngle);
dist := dist + incr;
end ;
Draw the spiral after asking the user to input values for the four parameters. Some values to
try are num = 100 and (dist,angle,incr) = (.1,144,.1), (.05,89.5,.05), (.05,170,.05), and (.05,60,.05).
The “ Clear ” command should clear the viewport except for the turtle. The “ MoveTo ” and
Direction ” command should have the obvious effect on the turtle.
When entering the turtle menu for the first time, the turtle should be initialized to “sit” at
the center of an empty viewport “looking” right. After that the program should not reinitialize
the turtle or clear the screen on its own, except that the screen should be cleared whenever the
Turtle menu is exited. The turtle should only be visible whenever one is inside the Turtle menu.
When outside the turtle menu, the graphics area should always be blank except for the pos-
sible dimension values.
Note: You do not have to worry about clipping the turtle's path to the window. In this program
it is the user's responsibility to ensure that the path lies entirely inside the window.
1.5.4 Turtle crawling on a cube ([AbeD81])
For this project change the main menu to
Search WWH ::




Custom Search