home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc / qc20 / turtle.h < prev   
Encoding:
C/C++ Source or Header  |  1988-11-22  |  3.8 KB  |  100 lines

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