home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / qc25 / beispiel / turtle.h < prev   
Encoding:
C/C++ Source or Header  |  1990-07-25  |  4.1 KB  |  107 lines

  1. /* Functionsprototypen, Makros, Structuren und Globalvariablen für
  2.  * Grafikfunktionen in Turtle.
  3.  */
  4.  
  5. /* Nur einmal einfügen */
  6. #ifndef TURTLE_H
  7. #define TURTLE_H
  8.  
  9. /* Initialisieren und Vorgaben einrichten */
  10. short InitTurtle( struct videoconfig *vc );
  11. short Home();
  12.  
  13. /* Stift und Farben steuern */
  14. int   StiftStatus( int status );
  15. short AusFuellung( short status );
  16. short StiftFarbe( short atrib );
  17. short RandFarbe( short rand );
  18.  
  19. /* Winkel bestimmen */
  20. short Schwenken( short winkel );
  21. short Richtung( short winkel );
  22.  
  23. /* Turtle-Bewegung */
  24. short Bewege( double entfernung );
  25. short GeheZu( double x, double y );
  26. short Poly( int nummer, double seite );
  27.  
  28. /* Farbindex oder -wert weiterdrehen */
  29. short FarbIndexWeiter( short fiGgw );
  30. void  FarbWertWeiter( int fAktion );
  31.  
  32. /* Zeichnet Kreis mit Radius <r> an gegenwärtiger Position. */
  33. #define Kreis( r ) _ellipse_w( tc.fFuell, tc.xGgw-(r), tc.yGgw-(r), \
  34.                                           tc.xGgw+(r), tc.yGgw+(r) )
  35.  
  36. /* Zeichnet Ellipse der Breite <b> und Höhe <h> an gegenwärtiger Position. */
  37. #define Ellipse( b, h ) _ellipse_w( tc.fFuell, \
  38.                                     tc.xGgw-((b)/2), tc.yGgw-((h)/2), \
  39.                                     tc.xGgw+((b)/2), tc.yGgw+((h)/2) )
  40.  
  41. /* Legt die Mitte eines Rechtecks der Breite <b> und Höhe <h>
  42.  * zu gegenwärtigen Position.
  43.  */
  44. #define Rechteck( b, h ) _rectangle_w( tc.fFuell, \
  45.                                         tc.xGgw-((b)/2), tc.yGgw-((h)/2), \
  46.                                         tc.xGgw+((b)/2), tc.yGgw+((h)/2) )
  47.  
  48. /* Holt Größe eines Bildes der Breite <b> und Höhe <h>, wobei die linke
  49.  * obere Ecke an gegenwärtiger Position liegt. Ergibt Abbildgröße.
  50.  */
  51. #define BildGroesse( b, h ) _imagesize_w( tc.xGgw, tc.yGgw, \
  52.                                         tc.xGgw+(b), tc.yGgw+(h) )
  53.  
  54. /* Holt ein Bild der Breite <b> und Höhe <h>, wobei die linke obere
  55.  * Ecke an gegenwärtiger Position liegt. Ergibt Bild-Zwischenspeicher.
  56.  */
  57. #define BildHolen( b,h,buf) _getimage_w( tc.xGgw, tc.yGgw, \
  58.                                         tc.xGgw+(b), tc.yGgw+(h), buf )
  59.  
  60. /* Legt mittels angegebenem Vorgang (_GPSET, _GPRESET, _GAND, _GOR, _GXOR)
  61.  * die linke obere Ecke eines bestimmten Bildes zur gegenwärtigen Position.
  62.  */
  63. #define BildPos( buf, act )  _putimage_w( tc.xGgw, tc.yGgw, buf, act )
  64.  
  65. /* Auffüllen von gegenwärtiger Position an bis zum Rand. */
  66. #define Fuellen() _floodfill_w( tc.xGgw, tc.yGgw, tc.fiRand )
  67.  
  68. /* Ergibt Wert ungleich Null, wenn gegenwärtige Position auf Bildschirm ist. */
  69. #define AufBildsch() (!((tc.xGgw < -tc.xMax) || (tc.xGgw > tc.xMax) || \
  70.                       (tc.yGgw < -tc.yMax) || (tc.yGgw > tc.yMax)))
  71.  
  72. /* Ergibt long int aus Rot-, Grün und Blau-Bytes. */
  73. #define RGB( r,g,b) (((long)((b) << 8 | (g)) << 8) | (r))
  74.  
  75. /* Konstanten */
  76. #define CIRCUMFERENCE     360
  77. #define HALFCIRCUMFERENCE 180
  78.  
  79. #define VORGABE -1
  80. #define GRENZE   0
  81. #define WAHR     1
  82. #define FALSCH   0
  83. #define WEISS (tc.afi - 1)
  84.  
  85. /* Strukturen für Konfiguration und andere Daten */
  86. typedef struct _TURTLE
  87. {
  88.     double  yxSeitenvh;             /* Seitenverhältnis Y - X         */
  89.     double  xMax, yMax;             /* Maximum x und y                */
  90.     double  yEinheit;               /* Größe eines Bildpunkte            */
  91.     double  xGgw, yGgw;             /* Gegenwärtige Position               */
  92.     short   afi;                    /* Anzahl der Farbindizes           */
  93.     short   afw;                    /* Anzahl der Farbwerte             */
  94.     short   fiGgw;                  /* Gegenwärtiger Farbindex          */
  95.     short   fiRand;                 /* Gegenwärtiger Rand-Farbindex     */
  96.     short   wklGgw;                 /* Gegenwärtiger Winkel             */
  97.     int     fStiftStatus;           /* Stift-Status                      */
  98.     int     fFuell;                 /* Füll-Status                     */
  99.     int     fPalette;               /* Verfügbare Paletten           */
  100.     short   xsLinks, xsRechts;      /* Absolute Eckwerte des Fensters   */
  101.     short   ysOben, ysUnten;
  102. } TURTLE;
  103.  
  104. extern TURTLE tc;
  105.  
  106. #endif /* TURTLE_H */
  107.