home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mi / mipoly.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-09  |  2.7 KB  |  102 lines

  1. /***********************************************************
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24. /* $XConsortium: mipoly.c,v 5.0 89/06/09 15:08:32 keith Exp $ */
  25. /*
  26.  *  mipoly.c
  27.  *
  28.  *  Written by Brian Kelleher; June 1986
  29.  *
  30.  *  Draw polygons.  This routine translates the point by the
  31.  *  origin if pGC->miTranslate is non-zero, and calls
  32.  *  to the appropriate routine to actually scan convert the
  33.  *  polygon.
  34.  */
  35. #include "X.h"
  36. #include "windowstr.h"
  37. #include "gcstruct.h"
  38. #include "pixmapstr.h"
  39. #include "mi.h"
  40. #include "miscstruct.h"
  41.  
  42.  
  43. void
  44. miFillPolygon(dst, pgc, shape, mode, count, pPts)
  45.     DrawablePtr        dst;
  46.     register GCPtr    pgc;
  47.     int            shape, mode;
  48.     register int    count;
  49.     DDXPointPtr        pPts;
  50. {
  51.     int            i;
  52.     register int    xorg, yorg;
  53.     register DDXPointPtr ppt;
  54.  
  55.     if (count == 0)
  56.     return;
  57.  
  58.     ppt = pPts;
  59.     if (pgc->miTranslate)
  60.     {
  61.     xorg = dst->x;
  62.     yorg = dst->y;
  63.  
  64.         if (mode == CoordModeOrigin) 
  65.         {
  66.             for (i = 0; i<count; i++) 
  67.                 {    
  68.                 ppt->x += xorg;
  69.                 ppt++->y += yorg;
  70.             }
  71.         }
  72.         else 
  73.         {
  74.         ppt->x += xorg;
  75.         ppt++->y += yorg;
  76.         for (i = 1; i<count; i++) 
  77.             {
  78.             ppt->x += (ppt-1)->x;
  79.             ppt->y += (ppt-1)->y;
  80.             ppt++;
  81.         }
  82.         }
  83.     }
  84.     else
  85.     {
  86.     if (mode == CoordModePrevious)
  87.         {
  88.         ppt++;
  89.         for (i = 1; i<count; i++) 
  90.             {
  91.             ppt->x += (ppt-1)->x;
  92.             ppt->y += (ppt-1)->y;
  93.             ppt++;
  94.         }
  95.         }
  96.     }
  97.     if (shape == Convex)
  98.     miFillConvexPoly(dst, pgc, count, pPts);
  99.     else
  100.     miFillGeneralPoly(dst, pgc, count, pPts);
  101. }
  102.