home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mi / mifillarc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-11  |  3.8 KB  |  160 lines

  1. /************************************************************
  2. Copyright 1989 by The Massachusetts Institute of Technology
  3.  
  4. Permission to use, copy, modify, and distribute this
  5. software and its documentation for any purpose and without
  6. fee is hereby granted, provided that the above copyright
  7. notice appear in all copies and that both that copyright
  8. notice and this permission notice appear in supporting
  9. documentation, and that the name of MIT not be used in
  10. advertising or publicity pertaining to distribution of the
  11. software without specific prior written permission.
  12. M.I.T. makes no representation about the suitability of
  13. this software for any purpose. It is provided "as is"
  14. without any express or implied warranty.
  15.  
  16. ********************************************************/
  17.  
  18. /* $XConsortium: mifillarc.h,v 5.4 90/10/06 13:55:43 rws Exp $ */
  19.  
  20. #define FULLCIRCLE (360 * 64)
  21.  
  22. typedef struct _miFillArc {
  23.     int xorg, yorg;
  24.     int y;
  25.     int dx, dy;
  26.     int e;
  27.     int ym, yk, xm, xk;
  28. } miFillArcRec;
  29.  
  30. #define miFillArcEmpty(arc) (!(arc)->angle2 || \
  31.                  !(arc)->width || !(arc)->height || \
  32.                  (((arc)->width == 1) && ((arc)->height & 1)))
  33.  
  34. #define miCanFillArc(arc) (((arc)->width == (arc)->height) || \
  35.                (((arc)->width <= 800) && ((arc)->height <= 800)))
  36.  
  37. extern void miFillArcSetup(), miFillArcSliceSetup();
  38.  
  39. #define MIFILLARCSETUP() \
  40.     x = 0; \
  41.     y = info.y; \
  42.     e = info.e; \
  43.     xk = info.xk; \
  44.     xm = info.xm; \
  45.     yk = info.yk; \
  46.     ym = info.ym; \
  47.     dx = info.dx; \
  48.     dy = info.dy; \
  49.     xorg = info.xorg; \
  50.     yorg = info.yorg
  51.  
  52. #define MIFILLARCSTEP(slw) \
  53.     e += yk; \
  54.     while (e >= 0) \
  55.     { \
  56.     x++; \
  57.     xk -= xm; \
  58.     e += xk; \
  59.     } \
  60.     y--; \
  61.     yk -= ym; \
  62.     slw = (x << 1) + dx; \
  63.     if ((e == xk) && (slw > 1)) \
  64.     slw--
  65.  
  66. #define MIFILLCIRCSTEP(slw) MIFILLARCSTEP(slw)
  67. #define MIFILLELLSTEP(slw) MIFILLARCSTEP(slw)
  68.  
  69. #define miFillArcLower(slw) (((y + dy) != 0) && ((slw > 1) || (e != xk)))
  70.  
  71. typedef struct _miSliceEdge {
  72.     int        x;
  73.     int     stepx;
  74.     int        deltax;
  75.     int        e;
  76.     int        dy;
  77.     int        dx;
  78. } miSliceEdgeRec, *miSliceEdgePtr;
  79.  
  80. typedef struct _miArcSlice {
  81.     miSliceEdgeRec edge1, edge2;
  82.     int min_top_y, max_top_y;
  83.     int min_bot_y, max_bot_y;
  84.     Bool edge1_top, edge2_top;
  85.     Bool flip_top, flip_bot;
  86. } miArcSliceRec;
  87.  
  88. #define MIARCSLICESTEP(edge) \
  89.     edge.x -= edge.stepx; \
  90.     edge.e -= edge.dx; \
  91.     if (edge.e <= 0) \
  92.     { \
  93.     edge.x -= edge.deltax; \
  94.     edge.e += edge.dy; \
  95.     }
  96.  
  97. #define miFillSliceUpper(slice) \
  98.         ((y >= slice.min_top_y) && (y <= slice.max_top_y))
  99.  
  100. #define miFillSliceLower(slice) \
  101.         ((y >= slice.min_bot_y) && (y <= slice.max_bot_y))
  102.  
  103. #define MIARCSLICEUPPER(xl,xr,slice,slw) \
  104.     xl = xorg - x; \
  105.     xr = xl + slw - 1; \
  106.     if (slice.edge1_top && (slice.edge1.x < xr)) \
  107.     xr = slice.edge1.x; \
  108.     if (slice.edge2_top && (slice.edge2.x > xl)) \
  109.     xl = slice.edge2.x;
  110.  
  111. #define MIARCSLICELOWER(xl,xr,slice,slw) \
  112.     xl = xorg - x; \
  113.     xr = xl + slw - 1; \
  114.     if (!slice.edge1_top && (slice.edge1.x > xl)) \
  115.     xl = slice.edge1.x; \
  116.     if (!slice.edge2_top && (slice.edge2.x < xr)) \
  117.     xr = slice.edge2.x;
  118.  
  119. #define MIWIDEARCSETUP(x,y,dy,slw,e,xk,xm,yk,ym) \
  120.     x = 0; \
  121.     y = slw >> 1; \
  122.     yk = y << 3; \
  123.     xm = 8; \
  124.     ym = 8; \
  125.     if (dy) \
  126.     { \
  127.     xk = 0; \
  128.     if (slw & 1) \
  129.         e = -1; \
  130.     else \
  131.         e = -(y << 2) - 2; \
  132.     } \
  133.     else \
  134.     { \
  135.     y++; \
  136.     yk += 4; \
  137.     xk = -4; \
  138.     if (slw & 1) \
  139.         e = -(y << 2) - 3; \
  140.     else \
  141.         e = - (y << 3); \
  142.     }
  143.  
  144. #define MIFILLINARCSTEP(slw) \
  145.     ine += inyk; \
  146.     while (ine >= 0) \
  147.     { \
  148.     inx++; \
  149.     inxk -= inxm; \
  150.     ine += inxk; \
  151.     } \
  152.     iny--; \
  153.     inyk -= inym; \
  154.     slw = (inx << 1) + dx; \
  155.     if ((ine == inxk) && (slw > 1)) \
  156.     slw--
  157.  
  158. #define miFillInArcLower(slw) (((iny + dy) != 0) && \
  159.                    ((slw > 1) || (ine != inxk)))
  160.