home *** CD-ROM | disk | FTP | other *** search
-
-
- Turtle Graphics Commands for Turbo C Programmer
-
- 31 December 1988
-
- Gerald K. Hobart
-
- For Turbo C programmers who would like to do some turtle
- graphics, the file TURTLE.C contains the following turtle
- graphics commands:
-
- void penup(void);
- void pendown(void);
- void forward(int dist);
- void back(int dist);
- void right(double angl);
- void left(double angl);
- void setheading(double deg);
- double getheading(void);
- int getpen(void);
-
- The file TURTLE.H contains the above function prototypes, and
- should be included in any module using these functions.
-
- ----------------------------------------------------------------
-
- penup();
- This command puts the pen in the UP position. While the pen
- is up, no drawing will take place. The pen is initially set
- to the UP position.
-
- pendown();
- This command puts the pen in the DOWN position. The pen
- must be DOWN for any drawing to be done by the forward() or
- back() commands.
-
- getpen();
- This function returns 1 if the pen is DOWN, 0 if the pen is
- UP.
-
- setheading(deg);
- This function sets the heading to 'deg' degrees, where:
-
- 0 degrees is towards the top of the screen
- 90 degrees is towards the right side of the screen
- 180 degrees is towards the bottom of the screen
- 270 degrees is towards the left side of the screen
-
- The argument 'deg' may be negative, and may exceed 360
- degrees, however the heading will always be normalized to a
- number between 0 and 360 degrees. The heading is initially
- set to 0 degrees.
-
- getheading();
- This function returns the current heading. This value will
- always be normalized to a value between 0 and 360 degrees.
-
- forward(dist);
- This command moves the pen forward a distance of 'dist'
- pixels. Forward means 'in the direction defined by the
- heading'. (See the setheading() command.) If the pen is
- DOWN when this command is given, a line will be drawn. If
- the pen is UP, the pen will be moved, but no line will be
- drawn.
-
- back(dist);
- This behaves the same as the forward command except the the
- pen is moved backwards instead of forwards.
-
- right(angl);
- This command changes the heading to the right by 'angl'
- degrees.
-
- left(angl);
- This command changes the heading to the left by 'angl'
- degrees.
-
- ----------------------------------------------------------------
-
- It should be relatively easy to convert this code for use with
- compilers other than Turbo C, providing of course there is a
- graphics library available.
-
- I would be interested in hearing about any additions,
- modifications, corrections or bug reports.
-
- Jerry Hobart
- 9700 Morrow NE
- Albuquerque, NM 87112
- (505) 298-0502
-
-
-