1
/* This file is part of the GNU libxmi package.
3
Copyright (C) 1985, 1986, 1987, 1988, 1989, X Consortium. For an
4
associated permission notice, see the accompanying file README-X.
6
GNU enhancements Copyright (C) 1998, 1999, 2000, 2005, Free Software
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.
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.
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. */
1
24
/* This module contains the miZeroLine() and miZeroDash() functions. They
2
25
a rasterize single-pixel (i.e., `zero-width') Bresenham polyline, either
36
59
y-coordinate of each endpoint after swapping. */
38
61
/* forward references */
39
static void cfbBresD ____P((miPaintedSet *paintedSet, const miGC *pGC, int *pdashNum, int *pdashIndex, const unsigned int *pDash, int numInDashList, int *pdashOffset, bool isDoubleDash, int signdx, int signdy, int axis, int x1, int y1, int e, int e1, int e2, int len));
40
static void cfbBresS ____P((miPaintedSet *paintedSet, const miGC *pGC, int signdx, int signdy, int axis, int x1, int y1, int e, int e1, int e2, int len));
41
static void cfbHorzS ____P((miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len));
42
static void cfbVertS ____P((miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len));
62
static void cfbBresD (miPaintedSet *paintedSet, const miGC *pGC, int *pdashNum, int *pdashIndex, const unsigned int *pDash, int numInDashList, int *pdashOffset, bool isDoubleDash, int signdx, int signdy, int axis, int x1, int y1, int e, int e1, int e2, int len);
63
static void cfbBresS (miPaintedSet *paintedSet, const miGC *pGC, int signdx, int signdy, int axis, int x1, int y1, int e, int e1, int e2, int len);
64
static void cfbHorzS (miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len);
65
static void cfbVertS (miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len);
45
68
/* Macro for painting a single point. Used for ending line segments. */
100
123
* Draw a solid Bresenham polyline, i.e. a `zero-width' solid polyline,
101
124
* in paint type #1.
127
/* ARGS: mode = Origin or Previous
128
npt = number of points
129
pPts = point array */
105
131
miZeroLine (miPaintedSet *paintedSet, const miGC *pGC, miCoordMode mode, int npt, const miPoint *pPts)
107
miZeroLine (paintedSet, pGC, mode, npt, pPts)
108
miPaintedSet *paintedSet;
110
miCoordMode mode; /* Origin or Previous */
111
int npt; /* number of points */
112
const miPoint *pPts; /* point array */
115
133
const miPoint *ppt; /* pointer to point within array */
116
134
/* temporaries */
238
256
* Draw a dashed Bresenham polyline, i.e. a `zero-width' dashed polyline.
259
/* ARGS: mode = Origin or Previous
260
npt = number of points
261
pPts = point array */
242
263
miZeroDash (miPaintedSet *paintedSet, const miGC *pGC, miCoordMode mode, int npt, const miPoint *pPts)
244
miZeroDash (paintedSet, pGC, mode, npt, pPts)
245
miPaintedSet *paintedSet;
247
miCoordMode mode; /* Origin or Previous */
248
int npt; /* number of points */
249
const miPoint *pPts; /* point array */
252
265
const miPoint *ppt; /* pointer to current point */
253
266
/* temporaries */
368
381
/* Internal: draw solid Bresenham line segment, in paint type #1. Called
369
382
by miZeroLine(). Endpoint semantics are used, i.e. we paint only len
370
383
pixels (i.e. |dx| or |dy| pixels), not including the endpoint. */
385
/* ARGS: signdx,signdy = signs of directions
386
axis = major axis (Y_AXIS or X_AXIS)
387
x1,y1 = initial point
388
e = error accumulator
389
e1,e2 = Bresenham increments
390
len = length of line in pixels */
373
392
cfbBresS (miPaintedSet *paintedSet, const miGC *pGC, int signdx, int signdy, int axis, int x1, int y1, int e, int e1, int e2, int len)
375
cfbBresS (paintedSet, pGC, signdx, signdy, axis, x1, y1, e, e1, e2, len)
376
miPaintedSet *paintedSet;
379
int signdy; /* signs of directions */
380
int axis; /* major axis (Y_AXIS or X_AXIS) */
381
int x1, y1; /* initial point */
382
int e; /* error accumulator */
383
int e1; /* Bresenham increments */
385
int len; /* length of line in pixels */
388
394
miPoint *pptInit, *pptLast;
389
395
unsigned int *pwidthInit, *pwidthLast;
472
478
/* Internal: draw dashed Bresenham line segment. Called by miZeroDash().
473
479
Endpoint semantics are used. */
481
/* ARGS: pdashNum = absolute dash number
482
pdashIndx = index into dash array
484
numInDashList = length of dash array
485
pdashOffset = offset into current dash
486
signdx,signdy = signs of directions
487
axis = major axis (Y_AXIS or X_AXIS)
488
x1,y1 = initial point
489
e = error accumulator
490
e1,e2 = Bresenham increments
491
len = length of line in pixels */
476
493
cfbBresD (miPaintedSet *paintedSet, const miGC *pGC, int *pdashNum, int *pdashIndex, const unsigned int *pDash, int numInDashList, int *pdashOffset, bool isDoubleDash, int signdx, int signdy, int axis, int x1, int y1, int e, int e1, int e2, int len)
478
cfbBresD (paintedSet, pGC, pdashNum, pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash, signdx, signdy, axis, x1, y1, e, e1, e2, len)
479
miPaintedSet *paintedSet;
481
int *pdashNum; /* absolute dash number */
482
int *pdashIndex; /* index into dash array */
483
const unsigned int *pDash; /* dash array */
484
int numInDashList; /* length of dash array */
485
int *pdashOffset; /* offset into current dash */
487
int signdx, signdy; /* signs of directions */
488
int axis; /* major axis (Y_AXIS or X_AXIS) */
489
int x1, y1; /* initial point */
490
int e; /* error accumulator */
491
int e1; /* Bresenham increments */
493
int len; /* length of line in pixels */
496
495
miPoint *pptInit_fg, *pptInit_bg = (miPoint *)NULL;
497
496
miPoint *pptLast_fg, *pptLast_bg = (miPoint *)NULL;
701
700
Called by miZeroLine().
702
701
Called with len >= 1, and len=x2-x1. Endpoint semantics
703
702
are used, so we paint only len pixels, i.e. x1..x2-1. */
704
/* ARGS: x1,y1 = initial point, len = length of line */
706
706
cfbHorzS (miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len)
708
cfbHorzS (paintedSet, pGC, x1, y1, len)
709
miPaintedSet *paintedSet;
711
int x1, y1; /* initial point */
712
int len; /* length of line */
716
709
unsigned int *pwidth;
729
722
Called by miZeroLine().
730
723
Called with len >= 1, and len=y2-y1. Endpoint semantics
731
724
are used, so we paint only len pixels, i.e. y1..y2-1. */
726
/* ARGS: x1,y1 = initial point, len = length of line */
734
728
cfbVertS (miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len)
736
cfbVertS (paintedSet, pGC, x1, y1, len)
737
miPaintedSet *paintedSet;
739
int x1, y1; /* initial point */
740
int len; /* length of line */
743
730
miPoint *ppt, *pptInit;
744
731
unsigned int *pwidth, *pwidthInit;