mi_line.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* This file is part of the GNU libxmi package.
  2. Copyright (C) 1985, 1986, 1987, 1988, 1989, X Consortium. For an
  3. associated permission notice, see the accompanying file README-X.
  4. GNU enhancements Copyright (C) 1998, 1999, 2000, 2005, Free Software
  5. Foundation, Inc.
  6. The GNU libxmi package is free software. You may redistribute it
  7. and/or modify it under the terms of the GNU General Public License as
  8. published by the Free Software foundation; either version 2, or (at your
  9. option) any later version.
  10. The GNU libxmi package is distributed in the hope that it will be
  11. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. General Public License for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with the GNU plotutils package; see the file COPYING. If not, write to
  16. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  17. Boston, MA 02110-1301, USA. */
  18. /* Stuff needed for drawing thin (zero width) lines */
  19. #define X_AXIS 0
  20. #define Y_AXIS 1
  21. #define OUT_LEFT 0x08
  22. #define OUT_RIGHT 0x04
  23. #define OUT_ABOVE 0x02
  24. #define OUT_BELOW 0x01
  25. #define MI_OUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \
  26. {\
  27. if (x < xmin) outcode |= OUT_LEFT;\
  28. if (x > xmax) outcode |= OUT_RIGHT;\
  29. if (y < ymin) outcode |= OUT_ABOVE;\
  30. if (y > ymax) outcode |= OUT_BELOW;\
  31. }
  32. #define round(dividend, divisor) \
  33. ( (((dividend)<<1) + (divisor)) / ((divisor)<<1) )
  34. #define ceiling(m,n) (((m)-1)/(n) + 1)
  35. #define SWAPINT(i, j) \
  36. { int _t = i; i = j; j = _t; }
  37. #define SWAPINT_PAIR(x1, y1, x2, y2)\
  38. { int t = x1; x1 = x2; x2 = t;\
  39. t = y1; y1 = y2; y2 = t;\
  40. }
  41. #define AbsDeltaAndSign(_p2, _p1, _absdelta, _sign) \
  42. (_sign) = 1; \
  43. (_absdelta) = (_p2) - (_p1); \
  44. if ( (_absdelta) < 0) { (_absdelta) = -(_absdelta); (_sign) = -1; }
  45. #ifndef FIXUP_X_MAJOR_ERROR
  46. #define FIXUP_X_MAJOR_ERROR(_e, _signdx, _signdy) \
  47. (_e) -= ( (_signdx) < 0)
  48. #endif
  49. #ifndef FIXUP_Y_MAJOR_ERROR
  50. #define FIXUP_Y_MAJOR_ERROR(_e, _signdx, _signdy) \
  51. (_e) -= ( (_signdy) < 0)
  52. #endif