1 /* This file is part of the GNU libxmi package.
2
3 Copyright (C) 1985, 1986, 1987, 1988, 1989, X Consortium. For an
4 associated permission notice, see the accompanying file README-X.
5
6 GNU enhancements Copyright (C) 1998, 1999, 2000, 2005, Free Software
7 Foundation, Inc.
8
9 The GNU libxmi package is free software. You may redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software foundation; either version 2, or (at your
12 option) any later version.
13
14 The GNU libxmi package is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License along
20 with the GNU plotutils package; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
22 Boston, MA 02110-1301, USA. */
23
24 #include "sys-defines.h"
25 #include "extern.h"
26
27 #include "xmi.h"
28 #include "mi_spans.h"
29 #include "mi_gc.h"
30 #include "mi_api.h"
31
32 /*
33 * Written by Brian Kelleher; June 1986
34 *
35 * Draw a polygon (supplied as a polyline, i.e. an array of points), via
36 * one of two scan conversion routines.
37 */
38
39 void
miFillPolygon_internal(miPaintedSet * paintedSet,const miGC * pGC,miPolygonShape shape,miCoordMode mode,int count,const miPoint * pPts)40 miFillPolygon_internal (miPaintedSet *paintedSet, const miGC *pGC, miPolygonShape shape, miCoordMode mode, int count, const miPoint *pPts)
41 {
42 miPoint *ppt = (miPoint *)NULL;
43 const miPoint *q;
44
45 /* ensure we have >=1 points */
46 if (count <= 0)
47 return;
48
49 if (mode == MI_COORD_MODE_PREVIOUS)
50 /* convert from relative to absolute coordinates */
51 {
52 int i;
53
54 ppt = (miPoint *)mi_xmalloc (count * sizeof(miPoint));
55 ppt[0] = pPts[0];
56 for (i = 1; i < count; i++)
57 {
58 ppt[i].x = ppt[i-1].x + pPts[i].x;
59 ppt[i].y = ppt[i-1].y + pPts[i].y;
60 }
61 q = ppt;
62 }
63 else
64 q = pPts;
65
66 switch ((int)shape)
67 {
68 case (int)MI_SHAPE_GENERAL:
69 default:
70 /* use general scan conversion routine */
71 miFillGeneralPoly (paintedSet, pGC, count, q);
72 break;
73 case (int)MI_SHAPE_CONVEX:
74 /* use special (faster) routine */
75 miFillConvexPoly (paintedSet, pGC, count, q);
76 break;
77 }
78
79 if (mode == MI_COORD_MODE_PREVIOUS)
80 free (ppt);
81 }
82
83
84