home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / voglw.zip / rect.c < prev    next >
C/C++ Source or Header  |  1997-02-13  |  2KB  |  106 lines

  1. #include "vogl.h"
  2.  
  3. /*
  4.  * rect
  5.  *
  6.  * draw a rectangle given two opposite corners
  7.  *
  8.  */
  9. void
  10. rect(x1, y1, x2, y2)
  11.     Coord     x1, y1, x2, y2;
  12. {
  13.     if (!vdevice.initialised)
  14.         verror("rect: vogl not initialised");
  15.  
  16.     move2(x1, y1);
  17.     draw2(x2, y1);
  18.     draw2(x2, y2);
  19.     draw2(x1, y2);
  20.     draw2(x1, y1);
  21. }
  22.  
  23. /*
  24.  * recti
  25.  *
  26.  * draw a rectangle given two opposite corners (expressed as integers)
  27.  */
  28. void
  29. recti(x1, y1, x2, y2)
  30.     Icoord     x1, y1, x2, y2;
  31. {
  32.     rect((Coord)x1, (Coord)y1, (Coord)x2, (Coord)y2);
  33. }
  34.  
  35. /*
  36.  * rects
  37.  *
  38.  * draw a rectangle given two opposite corners (expressed as short integers)
  39.  */
  40. void
  41. rects(x1, y1, x2, y2)
  42.     Scoord     x1, y1, x2, y2;
  43. {
  44.     rect((Coord)x1, (Coord)y1, (Coord)x2, (Coord)y2);
  45. }
  46.  
  47. /*
  48.  * rectf
  49.  *
  50.  * draw a filled rectangle given two opposite corners
  51.  *
  52.  */
  53. void
  54. rectf(x1, y1, x2, y2)
  55.     Coord     x1, y1, x2, y2;
  56. {
  57.     Token    *tok;
  58.  
  59.     if (!vdevice.initialised)
  60.         verror("rect: vogl not initialised");
  61.  
  62.     if (vdevice.inobject) {
  63.         tok = newtokens(5);
  64.         tok[0].i = RECTF;
  65.         tok[1].f = x1;
  66.         tok[2].f = y1;
  67.         tok[3].f = x2;
  68.         tok[4].f = y2;
  69.         return;
  70.     }
  71.         
  72.     pmv2(x1, y1);
  73.     pdr2(x2, y1);
  74.     pdr2(x2, y2);
  75.     pdr2(x1, y2);
  76.     pdr2(x1, y1);
  77.     pclos();
  78. }
  79.  
  80.  
  81. /*
  82.  * rectfi
  83.  *
  84.  * draw a filled rectangle given two opposite corners (expressed as integers)
  85.  */
  86. void
  87. rectfi(x1, y1, x2, y2)
  88.     Icoord     x1, y1, x2, y2;
  89. {
  90.     rectf((Coord)x1, (Coord)y1, (Coord)x2, (Coord)y2);
  91. }
  92.  
  93. /*
  94.  * rectfs
  95.  *
  96.  * draw a filled rectangle given two opposite corners (expressed as short
  97.  * integers)
  98.  */
  99. void
  100. rectfs(x1, y1, x2, y2)
  101.     Scoord     x1, y1, x2, y2;
  102. {
  103.     rectf((Coord)x1, (Coord)y1, (Coord)x2, (Coord)y2);
  104. }
  105.  
  106.