home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / VOGLE / SRC / RECT.C < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-11  |  1.1 KB  |  72 lines

  1. #include "vogle.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.     float     x1, y1, x2, y2;
  12. {
  13.     int    sync, flag = 0;
  14.  
  15.     if (!vdevice.initialised)
  16.         verror("rect: vogle not initialised");
  17.  
  18.     if ((vdevice.attr->a.fill || vdevice.attr->a.hatch) && !vdevice.inpolygon) {
  19.         flag = 1;
  20.         makepoly();        /* want it filled */
  21.     }
  22.  
  23.     if ((sync = vdevice.sync))
  24.         vdevice.sync = 0;
  25.  
  26.     move2(x1, y1);
  27.     draw2(x2, y1);
  28.     draw2(x2, y2);
  29.     draw2(x1, y2);
  30.  
  31.     if (flag)
  32.         closepoly();
  33.     else
  34.         draw2(x1, y1);
  35.  
  36.     if (sync) {
  37.         vdevice.sync = 1;
  38.         (*vdevice.dev.Vsync)();
  39.     }
  40. }
  41.  
  42. /*
  43.  * srect
  44.  *
  45.  * draw a rectangle given two opposite corners in screen coords.
  46.  *
  47.  */
  48. void
  49. srect(x1, y1, x2, y2)
  50.     float     x1, y1, x2, y2;
  51. {
  52.     int    sync;
  53.  
  54.     if (!vdevice.initialised)
  55.         verror("rect: vogle not initialised");
  56.  
  57.     if ((sync = vdevice.sync))
  58.         vdevice.sync = 0;
  59.  
  60.     smove2(x1, y1);
  61.     sdraw2(x2, y1);
  62.     sdraw2(x2, y2);
  63.     sdraw2(x1, y2);
  64.  
  65.     sdraw2(x1, y1);
  66.  
  67.     if (sync) {
  68.         vdevice.sync = 1;
  69.         (*vdevice.dev.Vsync)();
  70.     }
  71. }
  72.