~ubuntu-branches/ubuntu/jaunty/plotutils/jaunty

« back to all changes in this revision

Viewing changes to libxmi/mi_zerolin.c

  • Committer: Bazaar Package Importer
  • Author(s): Floris Bruynooghe
  • Date: 2007-05-10 19:48:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070510194854-mrr3lgwzpxd8hovo
Tags: 2.5-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
1
24
/* This module contains the miZeroLine() and miZeroDash() functions.  They
2
25
   a rasterize single-pixel (i.e., `zero-width') Bresenham polyline, either
3
26
   solid or dashed.
36
59
   y-coordinate of each endpoint after swapping. */
37
60
 
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);
43
66
 
44
67
 
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.
102
125
 */
 
126
 
 
127
/* ARGS: mode = Origin or Previous
 
128
         npt = number of points
 
129
         pPts = point array */
103
130
void
104
 
#ifdef _HAVE_PROTOS
105
131
miZeroLine (miPaintedSet *paintedSet, const miGC *pGC, miCoordMode mode, int npt, const miPoint *pPts)
106
 
#else
107
 
miZeroLine (paintedSet, pGC, mode, npt, pPts)
108
 
     miPaintedSet *paintedSet;
109
 
     const miGC *pGC;
110
 
     miCoordMode mode;          /* Origin or Previous */
111
 
     int npt;                   /* number of points */
112
 
     const miPoint *pPts;       /* point array */
113
 
#endif
114
132
{
115
133
  const miPoint *ppt;   /* pointer to point within array */
116
134
  /* temporaries */
237
255
/*
238
256
 * Draw a dashed Bresenham polyline, i.e. a `zero-width' dashed polyline.
239
257
 */
 
258
 
 
259
/* ARGS: mode = Origin or Previous
 
260
         npt = number of points
 
261
         pPts = point array */
240
262
void
241
 
#ifdef _HAVE_PROTOS
242
263
miZeroDash (miPaintedSet *paintedSet, const miGC *pGC, miCoordMode mode, int npt, const miPoint *pPts)
243
 
#else
244
 
miZeroDash (paintedSet, pGC, mode, npt, pPts)
245
 
     miPaintedSet *paintedSet;
246
 
     const miGC *pGC;
247
 
     miCoordMode mode;          /* Origin or Previous */
248
 
     int npt;                   /* number of points */
249
 
     const miPoint *pPts;       /* point array */
250
 
#endif
251
264
{
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. */
 
384
 
 
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 */
371
391
static void
372
 
#ifdef _HAVE_PROTOS
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)
374
 
#else
375
 
cfbBresS (paintedSet, pGC, signdx, signdy, axis, x1, y1, e, e1, e2, len)
376
 
     miPaintedSet   *paintedSet;
377
 
     const miGC     *pGC;
378
 
     int            signdx;
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 */
384
 
     int            e2;
385
 
     int            len;                /* length of line in pixels */
386
 
#endif
387
393
{
388
394
  miPoint *pptInit, *pptLast;
389
395
  unsigned int *pwidthInit, *pwidthLast;
471
477
 
472
478
/* Internal: draw dashed Bresenham line segment. Called by miZeroDash().
473
479
   Endpoint semantics are used. */
 
480
 
 
481
/* ARGS: pdashNum = absolute dash number
 
482
         pdashIndx = index into dash array
 
483
         pDash = 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 */
474
492
static void
475
 
#ifdef _HAVE_PROTOS
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)
477
 
#else
478
 
cfbBresD (paintedSet, pGC, pdashNum, pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash, signdx, signdy, axis, x1, y1, e, e1, e2, len)
479
 
     miPaintedSet   *paintedSet;
480
 
     const miGC     *pGC;
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 */
486
 
     bool           isDoubleDash;
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 */
492
 
     int            e2;
493
 
     int            len;                /* length of line in pixels */
494
 
#endif
495
494
{
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. */
 
703
 
 
704
/* ARGS: x1,y1 = initial point, len = length of line */
704
705
static void
705
 
#ifdef _HAVE_PROTOS
706
706
cfbHorzS (miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len)
707
 
#else
708
 
cfbHorzS (paintedSet, pGC, x1, y1, len)
709
 
     miPaintedSet *paintedSet;
710
 
     const miGC *pGC;
711
 
     int        x1, y1;         /* initial point */ 
712
 
     int        len;            /* length of line */
713
 
#endif
714
707
{
715
708
  miPoint *ppt;
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. */
 
725
 
 
726
/* ARGS: x1,y1 = initial point, len = length of line */
732
727
static void
733
 
#ifdef _HAVE_PROTOS
734
728
cfbVertS (miPaintedSet *paintedSet, const miGC *pGC, int x1, int y1, int len)
735
 
#else
736
 
cfbVertS (paintedSet, pGC, x1, y1, len)
737
 
     miPaintedSet *paintedSet;
738
 
     const miGC *pGC;
739
 
     int        x1, y1;         /* initial point */
740
 
     int        len;            /* length of line */
741
 
#endif
742
729
{
743
730
  miPoint *ppt, *pptInit;
744
731
  unsigned int *pwidth, *pwidthInit;