home *** CD-ROM | disk | FTP | other *** search
- (****************************************************************************)
- (* *)
- (* MODULE: Turtle.Lib 1.00 *)
- (* AUTHOR: Tim Meekins *)
- (* DATE: September 26, 1986 *)
- (* *)
- (* This library contains numerous functions and procedures allowing turtle *)
- (* graphics like commands. These routines use a standard cartesian coord- *)
- (* inate system with (0,0) being in the center of the paper. The internal *)
- (* variables keep track of the "turtle's" current x,y position and it's *)
- (* heading. You can also specify whether it will be drawing when it moves *)
- (* with PENUP and PENDOWN procedures. The "turtle" is moved by simply using *)
- (* the TMOVE procedure and a distance as a parameter. The TURN procedure *)
- (* will make the "turtle" the number of angle units in the passed parameter.*)
- (* *)
- (* Turtle.lib requires that the host program also include the Diablo.lib *)
- (* module for the basic graphics (printer) commands. *)
- (* *)
- (* Ver 1.00 09-26-86 Initial program written. *)
- (* *)
- (****************************************************************************)
-
-
- { Initialize the Turtle Graphics mode }
- { Init_Diablo, need not be called }
- { before accessing this. }
-
- PROCEDURE init_turtle;
- BEGIN
- init_diablo;
- move(250,250);
- t_pen := false;
- t_x := 0;
- t_y := 0;
- t_ang := 0
- END;
-
- { The following two procedures set }
- { the drawing mode. }
-
- PROCEDURE pen_up;
- BEGIN
- t_pen := false
- END;
-
- PROCEDURE pen_down;
- BEGIN
- t_pen := true
- END;
-
- { These are the moving and drawing procedures }
-
- PROCEDURE t_moveto(x,y : integer);
- BEGIN
- CASE t_pen OF
- false : move(x+250,250-y);
- true : drawto(x+250,250-y)
- END;
- t_x := x; t_y := y
- END;
-
- PROCEDURE t_move(distance : integer);
- BEGIN
- t_x := round(t_x + distance * cos(t_ang * 0.01744533));
- t_y := round(t_y + distance * sin(t_ang * 0.01744533));
- t_moveto(t_x,t_y)
- END;
-
- { These are the turning procedures }
-
- PROCEDURE turnto(angle : integer);
- BEGIN
- WHILE angle > 360 DO
- angle := angle - 360;
- WHILE angle < -360 DO
- angle := angle + 360;
- IF angle < 0 THEN
- angle := 360 - angle;
- t_ang := angle
- END;
-
- PROCEDURE turn(angle : integer);
- BEGIN
- turnto(t_ang + angle)
- END;