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 /* Stuff needed for drawing thin (zero width) lines */
25 
26 #define X_AXIS	0
27 #define Y_AXIS	1
28 
29 #define OUT_LEFT  0x08
30 #define OUT_RIGHT 0x04
31 #define OUT_ABOVE 0x02
32 #define OUT_BELOW 0x01
33 
34 #define MI_OUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \
35 {\
36      if (x < xmin) outcode |= OUT_LEFT;\
37      if (x > xmax) outcode |= OUT_RIGHT;\
38      if (y < ymin) outcode |= OUT_ABOVE;\
39      if (y > ymax) outcode |= OUT_BELOW;\
40 }
41 
42 #define round(dividend, divisor) \
43 ( (((dividend)<<1) + (divisor)) / ((divisor)<<1) )
44 
45 #define ceiling(m,n)  (((m)-1)/(n) + 1)
46 
47 #define SWAPINT(i, j) \
48 {  int _t = i;  i = j;  j = _t; }
49 
50 #define SWAPINT_PAIR(x1, y1, x2, y2)\
51 {   int t = x1;  x1 = x2;  x2 = t;\
52         t = y1;  y1 = y2;  y2 = t;\
53 }
54 
55 #define AbsDeltaAndSign(_p2, _p1, _absdelta, _sign) \
56     (_sign) = 1; \
57     (_absdelta) = (_p2) - (_p1); \
58     if ( (_absdelta) < 0) { (_absdelta) = -(_absdelta); (_sign) = -1; }
59 
60 #ifndef FIXUP_X_MAJOR_ERROR
61 #define FIXUP_X_MAJOR_ERROR(_e, _signdx, _signdy) \
62     (_e) -= ( (_signdx) < 0)
63 #endif
64 
65 #ifndef FIXUP_Y_MAJOR_ERROR
66 #define FIXUP_Y_MAJOR_ERROR(_e, _signdx, _signdy) \
67     (_e) -= ( (_signdy) < 0)
68 #endif
69 
70