home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c034 / 4.ddi / SOURCE / TURTLE.H$ / TURTLE.bin
Encoding:
Text File  |  1990-01-18  |  3.9 KB  |  106 lines

  1. /* Function prototypes, macros, structure, and global variables for
  2.  * Turtle Graphics functions.
  3.  */
  4.  
  5. /* Include only once */
  6. #ifndef TURTLE_H
  7. #define TURTLE_H
  8.  
  9. /* Initiate and set defaults */
  10. short InitTurtle( struct videoconfig *vc );
  11. short Home( void );
  12.  
  13. /* Control pen and color */
  14. int   PenDown( int state );
  15. short SetFill( short state );
  16. short PenColor( short atrib );
  17. short BorderColor( short border );
  18.  
  19. /* Control angle */
  20. short Turn( short angle );
  21. short TurnTo( short angle );
  22.  
  23. /* Turtle movement */
  24. short Move( double distance );
  25. short MoveTo( double x, double y );
  26. short Poly( int number, double side );
  27.  
  28. /* Rotate color index or value */
  29. short NextColorIndex( short ciCur );
  30. void  NextColorValue( int fAction );
  31.  
  32. /* Put a circle with radius <r> at current location. */
  33. #define Circle( r ) _ellipse_w( tc.fFill, tc.xCur-(r), tc.yCur-(r), \
  34.                                           tc.xCur+(r), tc.yCur+(r) )
  35.  
  36. /* Puts an ellipse with width <w> and height <h> at current location. */
  37. #define Ellipse( w, h ) _ellipse_w( tc.fFill, \
  38.                                     tc.xCur-((w)/2), tc.yCur-((h)/2), \
  39.                                     tc.xCur+((w)/2), tc.yCur+((h)/2) )
  40.  
  41. /* Puts the center of a rectangle with width <w> and height <h>
  42.  * at current location.
  43.  */
  44. #define Rectangle( w, h ) _rectangle_w( tc.fFill, \
  45.                                         tc.xCur-((w)/2), tc.yCur-((h)/2), \
  46.                                         tc.xCur+((w)/2), tc.yCur+((h)/2) )
  47.  
  48. /* Gets the imagesize of an image with width <w> and height <h>
  49.  * with left-top at current location. Returns image size.
  50.  */
  51. #define ImageSize( w, h ) _imagesize_w( tc.xCur, tc.yCur, \
  52.                                         tc.xCur+(w), tc.yCur+(h) )
  53.  
  54. /* Gets an image with width <w> and height <h> with left-top
  55.  * at current location. Returns image buffer.
  56.  */
  57. #define GetImage( w,h,buf) _getimage_w( tc.xCur, tc.yCur, \
  58.                                         tc.xCur+(w), tc.yCur+(h), buf )
  59.  
  60. /* Puts the top-left corner of a specified image at current location
  61.  * using a specified action (_GPSET, _GPRESET, _GAND, _GOR, _GXOR).
  62.  */
  63. #define PutImage( buf, act )  _putimage_w( tc.xCur, tc.yCur, buf, act )
  64.  
  65. /* Fills starting at the current location and continues to border. */
  66. #define FillIn() _floodfill_w( tc.xCur, tc.yCur, tc.ciBorder )
  67.  
  68. /* Returns nonzero if the current location is onscreen. */
  69. #define OnScreen() (!((tc.xCur < -tc.xMax) || (tc.xCur > tc.xMax) || \
  70.                       (tc.yCur < -tc.yMax) || (tc.yCur > tc.yMax)))
  71.  
  72. /* Returns a long int mixed from red, green, and blue bytes. */
  73. #define RGB( r,g,b) (((long)((b) << 8 | (g)) << 8) | (r))
  74.  
  75. /* Constants */
  76. #define CIRCUMFERENCE     360
  77. #define HALFCIRCUMFERENCE 180
  78.  
  79. #define DEFAULT -1
  80. #define LIMITED  0
  81. #define TRUE     1
  82. #define FALSE    0
  83. #define WHITE (tc.cci - 1)
  84.  
  85. /* Structures for configuration and other data */
  86. typedef struct _TURTLE
  87. {
  88.     double  yxRatio;                /* Y to X aspect ratio          */
  89.     double  xMax, yMax;             /* Maximum x and y              */
  90.     double  yUnit;                  /* Window size of one pixel     */
  91.     double  xCur, yCur;             /* Current position             */
  92.     short   cci;                    /* Count of color indexes       */
  93.     short   ccv;                    /* Count of color values        */
  94.     short   ciCur;                  /* Current color index          */
  95.     short   ciBorder;               /* Current border color index   */
  96.     short   angCur;                 /* Current angle                */
  97.     int     fPenDown;               /* Pen state                    */
  98.     int     fFill;                  /* Fill state                   */
  99.     int     fPalette;               /* Palette availability         */
  100.     short   xsLeft, xsRight;        /* Absolute window corners      */
  101.     short   ysTop, ysBot;
  102. } TURTLE;
  103. extern TURTLE tc;
  104.  
  105. #endif /* TURTLE_H */
  106.