mi_plypnt.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /* This routine paints a set of points. All painting goes through the
  25. low-level MI_PAINT_SPANS() macro. */
  26. /* ARGS: mode = Origin or Previous */
  27. void
  28. miDrawPoints_internal (miPaintedSet *paintedSet, const miGC *pGC, miCoordMode mode, int npt, const miPoint *pPts)
  29. {
  30. unsigned int *pwidthInit, *pwidth;
  31. int i;
  32. miPoint *ppt = (miPoint *)NULL;
  33. /* ensure we have >=1 points */
  34. if (npt <= 0)
  35. return;
  36. ppt = (miPoint *)mi_xmalloc (npt * sizeof(miPoint));
  37. if (mode == MI_COORD_MODE_PREVIOUS)
  38. /* convert from relative to absolute coordinates */
  39. {
  40. ppt[0] = pPts[0];
  41. for (i = 1; i < npt; i++)
  42. {
  43. ppt[i].x = ppt[i-1].x + pPts[i].x;
  44. ppt[i].y = ppt[i-1].y + pPts[i].y;
  45. }
  46. }
  47. else
  48. /* just copy */
  49. {
  50. for (i = 0; i < npt; i++)
  51. ppt[i] = pPts[i];
  52. }
  53. pwidthInit = (unsigned int *)mi_xmalloc (npt * sizeof(unsigned int));
  54. pwidth = pwidthInit;
  55. for (i = 0; i < npt; i++)
  56. *pwidth++ = 1;
  57. if (npt > 1)
  58. miQuickSortSpansY (ppt, pwidthInit, npt);
  59. MI_PAINT_SPANS(paintedSet, pGC->pixels[1], npt, ppt, pwidthInit)
  60. }