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 /* This routine paints a set of points. All painting goes through the
33 low-level MI_PAINT_SPANS() macro. */
34
35 /* ARGS: mode = Origin or Previous */
36 void
miDrawPoints_internal(miPaintedSet * paintedSet,const miGC * pGC,miCoordMode mode,int npt,const miPoint * pPts)37 miDrawPoints_internal (miPaintedSet *paintedSet, const miGC *pGC, miCoordMode mode, int npt, const miPoint *pPts)
38 {
39 unsigned int *pwidthInit, *pwidth;
40 int i;
41 miPoint *ppt = (miPoint *)NULL;
42
43 /* ensure we have >=1 points */
44 if (npt <= 0)
45 return;
46
47 ppt = (miPoint *)mi_xmalloc (npt * sizeof(miPoint));
48 if (mode == MI_COORD_MODE_PREVIOUS)
49 /* convert from relative to absolute coordinates */
50 {
51 ppt[0] = pPts[0];
52 for (i = 1; i < npt; i++)
53 {
54 ppt[i].x = ppt[i-1].x + pPts[i].x;
55 ppt[i].y = ppt[i-1].y + pPts[i].y;
56 }
57 }
58 else
59 /* just copy */
60 {
61 for (i = 0; i < npt; i++)
62 ppt[i] = pPts[i];
63 }
64
65 pwidthInit = (unsigned int *)mi_xmalloc (npt * sizeof(unsigned int));
66 pwidth = pwidthInit;
67 for (i = 0; i < npt; i++)
68 *pwidth++ = 1;
69
70 if (npt > 1)
71 miQuickSortSpansY (ppt, pwidthInit, npt);
72 MI_PAINT_SPANS(paintedSet, pGC->pixels[1], npt, ppt, pwidthInit)
73 }
74
75