mi_fllrct.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include "sys-defines.h"
  19. #include "extern.h"
  20. #include "xmi.h"
  21. #include "mi_spans.h"
  22. #include "mi_gc.h"
  23. #include "mi_api.h"
  24. /* mi rectangles
  25. written by Todd Newman, with debts to all and sundry
  26. */
  27. /* Very straightforward. We let the low-level paint function invoked by
  28. * MI_PAINT_SPANS() worry about clipping to the destination.
  29. *
  30. * Note libxmi's convention: right edges and bottom edges of filled
  31. * polygons (including rectangles) are unpainted, so that adjacent polygons
  32. * will abut with no overlaps or gaps. */
  33. void
  34. miFillRectangles_internal (miPaintedSet *paintedSet, const miGC *pGC, int nrects, const miRectangle *prectInit)
  35. {
  36. const miRectangle *prect;
  37. /* ensure we have >=1 rects to fill */
  38. if (nrects <= 0)
  39. return;
  40. prect = prectInit;
  41. while (nrects--)
  42. {
  43. miPoint *ppt;
  44. miPoint *pptFirst;
  45. int xorg, yorg;
  46. unsigned int *pw, *pwFirst;
  47. unsigned int height, width, countdown;
  48. height = prect->height;
  49. width = prect->width;
  50. pptFirst = (miPoint *)mi_xmalloc (height * sizeof(miPoint));
  51. pwFirst = (unsigned int *)mi_xmalloc (height * sizeof(unsigned int));
  52. ppt = pptFirst;
  53. pw = pwFirst;
  54. xorg = prect->x;
  55. yorg = prect->y;
  56. countdown = height;
  57. while (countdown--)
  58. {
  59. *pw++ = width;
  60. ppt->x = xorg;
  61. ppt->y = yorg;
  62. ppt++;
  63. yorg++;
  64. }
  65. /* paint to paintedSet, or if that's NULL, to canvas */
  66. MI_PAINT_SPANS(paintedSet, pGC->pixels[1], (int)height, pptFirst, pwFirst)
  67. prect++;
  68. }
  69. }