i_path.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* This file contains the internal paint_path() and paint_paths() methods,
  16. which the public method endpath() is a wrapper around. */
  17. /* This version is for GIF Plotters. By construction, for GIF Plotters our
  18. path buffer always contains either a segment list, or an ellipse object.
  19. If it's a segment list, it contains either (1) a sequence of line
  20. segments, or (2) a single circular or elliptic arc segment. Those are
  21. all sorts of path that libxmi can handle. (For an ellipse or
  22. circular/elliptic arc segment to have been added to the path buffer, the
  23. map from user to device coordinates must preserve axes.) */
  24. #include "sys-defines.h"
  25. #include "extern.h"
  26. #include "xmi.h" /* use libxmi scan conversion module */
  27. #define DIST(p1, p2) sqrt( ((p1).x - (p2).x) * ((p1).x - (p2).x) \
  28. + ((p1).y - (p2).y) * ((p1).y - (p2).y))
  29. void
  30. _pl_i_paint_path (S___(Plotter *_plotter))
  31. {
  32. if (_plotter->drawstate->pen_type == 0
  33. && _plotter->drawstate->fill_type == 0)
  34. /* nothing to draw */
  35. return;
  36. switch ((int)_plotter->drawstate->path->type)
  37. {
  38. case (int)PATH_SEGMENT_LIST:
  39. {
  40. int i, polyline_len;
  41. bool identical_user_coordinates = true;
  42. double xu_last, yu_last;
  43. miGC *pGC;
  44. miPoint *miPoints, offset;
  45. miPixel fgPixel, bgPixel;
  46. miPixel pixels[2];
  47. plPoint p0, p1, pc;
  48. /* sanity checks */
  49. if (_plotter->drawstate->path->num_segments == 0)/* nothing to do */
  50. break;
  51. if (_plotter->drawstate->path->num_segments == 1)/* shouldn't happen */
  52. break;
  53. if (_plotter->drawstate->path->num_segments == 2
  54. && _plotter->drawstate->path->segments[1].type == S_ARC)
  55. /* segment buffer contains a single circular arc, not a polyline */
  56. {
  57. p0 = _plotter->drawstate->path->segments[0].p;
  58. p1 = _plotter->drawstate->path->segments[1].p;
  59. pc = _plotter->drawstate->path->segments[1].pc;
  60. /* use libxmi rendering */
  61. _pl_i_draw_elliptic_arc (R___(_plotter) p0, p1, pc);
  62. break;
  63. }
  64. if (_plotter->drawstate->path->num_segments == 2
  65. && _plotter->drawstate->path->segments[1].type == S_ELLARC)
  66. /* segment buffer contains a single elliptic arc, not a polyline */
  67. {
  68. p0 = _plotter->drawstate->path->segments[0].p;
  69. p1 = _plotter->drawstate->path->segments[1].p;
  70. pc = _plotter->drawstate->path->segments[1].pc;
  71. /* use libxmi rendering */
  72. _pl_i_draw_elliptic_arc_2 (R___(_plotter) p0, p1, pc);
  73. break;
  74. }
  75. /* neither of above applied, so segment buffer contains a polyline,
  76. not an arc */
  77. /* construct point array for libxmi module; convert vertices to
  78. device coordinates, removing runs */
  79. miPoints = (miPoint *)_pl_xmalloc (_plotter->drawstate->path->num_segments * sizeof(miPoint));
  80. polyline_len = 0;
  81. xu_last = 0.0;
  82. yu_last = 0.0;
  83. identical_user_coordinates = true;
  84. for (i = 0; i < _plotter->drawstate->path->num_segments; i++)
  85. {
  86. double xu, yu;
  87. int device_x, device_y;
  88. xu = _plotter->drawstate->path->segments[i].p.x;
  89. yu = _plotter->drawstate->path->segments[i].p.y;
  90. if (i > 0 && (xu != xu_last || yu != yu_last))
  91. /* in user space, not all points are the same */
  92. identical_user_coordinates = false;
  93. device_x = IROUND(XD(xu, yu));
  94. device_y = IROUND(YD(xu, yu));
  95. if ((polyline_len == 0)
  96. || (device_x != miPoints[polyline_len-1].x)
  97. || (device_y != miPoints[polyline_len-1].y))
  98. /* add point, in integer device coordinates, to the array */
  99. {
  100. miPoints[polyline_len].x = device_x;
  101. miPoints[polyline_len].y = device_y;
  102. polyline_len++;
  103. }
  104. xu_last = xu;
  105. yu_last = yu;
  106. }
  107. /* determine background pixel color */
  108. bgPixel.type = MI_PIXEL_INDEX_TYPE;
  109. bgPixel.u.index = _plotter->drawstate->i_bg_color_index;
  110. pixels[0] = bgPixel;
  111. pixels[1] = bgPixel;
  112. /* construct an miGC (graphics context for the libxmi module); copy
  113. attributes from the Plotter's GC to it */
  114. pGC = miNewGC (2, pixels);
  115. _set_common_mi_attributes (_plotter->drawstate, (void *)pGC);
  116. if (_plotter->drawstate->fill_type)
  117. /* not transparent, will fill */
  118. {
  119. /* flattened drawing primitives, i.e., box/circle/ellipse,
  120. are always convex */
  121. miPolygonShape polygon_shape
  122. = (_plotter->drawstate->path->primitive ? MI_SHAPE_CONVEX : MI_SHAPE_GENERAL);
  123. /* set fg color in GC (and bg color too) */
  124. _pl_i_set_fill_color (S___(_plotter));
  125. fgPixel.type = MI_PIXEL_INDEX_TYPE;
  126. fgPixel.u.index = _plotter->drawstate->i_fill_color_index;
  127. pixels[0] = bgPixel;
  128. pixels[1] = fgPixel;
  129. miSetGCPixels (pGC, 2, pixels);
  130. /* do the filling */
  131. if (_plotter->drawstate->path->num_segments > 1
  132. && polyline_len == 1)
  133. /* special case: all user-space points in polyline were
  134. mapped to a single integer pixel, so just paint it */
  135. miDrawPoints ((miPaintedSet *)_plotter->i_painted_set, pGC,
  136. MI_COORD_MODE_ORIGIN, 1, miPoints);
  137. else
  138. /* normal case */
  139. miFillPolygon ((miPaintedSet *)_plotter->i_painted_set, pGC,
  140. polygon_shape,
  141. MI_COORD_MODE_ORIGIN, polyline_len, miPoints);
  142. }
  143. if (_plotter->drawstate->pen_type)
  144. /* pen is present, so edge the polyline */
  145. {
  146. /* set fg color in GC (and bg color too) */
  147. _pl_i_set_pen_color (S___(_plotter));
  148. fgPixel.type = MI_PIXEL_INDEX_TYPE;
  149. fgPixel.u.index = _plotter->drawstate->i_pen_color_index;
  150. pixels[0] = bgPixel;
  151. pixels[1] = fgPixel;
  152. miSetGCPixels (pGC, 2, pixels);
  153. if (polyline_len == 1)
  154. /* All user-space points in the polyline were mapped to a
  155. single pixel. If (1) they weren't all the same to begin
  156. with, or (2) they were all the same to begin with and the
  157. cap mode is "round", then draw as a filled circle of
  158. diameter equal to the line width; otherwise draw
  159. nothing. */
  160. {
  161. if (identical_user_coordinates == false
  162. || _plotter->drawstate->cap_type == PL_CAP_ROUND)
  163. {
  164. unsigned int sp_size
  165. = (unsigned int)_plotter->drawstate->quantized_device_line_width;
  166. if (sp_size == 0)
  167. sp_size = 1;
  168. if (sp_size == 1)
  169. /* subcase: just draw a point */
  170. miDrawPoints ((miPaintedSet *)_plotter->i_painted_set, pGC,
  171. MI_COORD_MODE_ORIGIN, 1, miPoints);
  172. else
  173. /* draw a filled circle */
  174. {
  175. int sp_offset;
  176. miArc arc;
  177. sp_offset =
  178. (_plotter->drawstate->quantized_device_line_width + 1) / 2;
  179. arc.x = miPoints[0].x - sp_offset;
  180. arc.y = miPoints[0].y - sp_offset;
  181. arc.width = sp_size;
  182. arc.height = sp_size;
  183. arc.angle1 = 0;
  184. arc.angle2 = 64 * 360;
  185. miFillArcs ((miPaintedSet *)_plotter->i_painted_set,
  186. pGC, 1, &arc);
  187. }
  188. }
  189. }
  190. else
  191. /* normal case: draw a nondegenerate polyline in integer
  192. device space */
  193. miDrawLines ((miPaintedSet *)_plotter->i_painted_set, pGC,
  194. MI_COORD_MODE_ORIGIN, polyline_len, miPoints);
  195. }
  196. /* deallocate miGC and free temporary points array */
  197. miDeleteGC (pGC);
  198. free (miPoints);
  199. /* copy from painted set to canvas, and clear */
  200. offset.x = 0;
  201. offset.y = 0;
  202. miCopyPaintedSetToCanvas ((miPaintedSet *)_plotter->i_painted_set,
  203. (miCanvas *)_plotter->i_canvas,
  204. offset);
  205. miClearPaintedSet ((miPaintedSet *)_plotter->i_painted_set);
  206. }
  207. /* something was drawn in frame */
  208. _plotter->i_frame_nonempty = true;
  209. break;
  210. case (int)PATH_ELLIPSE:
  211. {
  212. int ninetymult;
  213. int x_orientation, y_orientation;
  214. int xorigin, yorigin;
  215. unsigned int squaresize_x, squaresize_y;
  216. plPoint pc;
  217. double rx, ry, angle;
  218. pc = _plotter->drawstate->path->pc;
  219. rx = _plotter->drawstate->path->rx;
  220. ry = _plotter->drawstate->path->ry;
  221. angle = _plotter->drawstate->path->angle;
  222. /* if angle is multiple of 90 degrees, modify to permit use of
  223. libxmi's arc rendering */
  224. ninetymult = IROUND(angle / 90.0);
  225. if (angle == (double) (90 * ninetymult))
  226. {
  227. angle = 0.0;
  228. if (ninetymult % 2)
  229. {
  230. double temp;
  231. temp = rx;
  232. rx = ry;
  233. ry = temp;
  234. }
  235. }
  236. rx = (rx < 0.0 ? -rx : rx); /* avoid obscure libxmi problems */
  237. ry = (ry < 0.0 ? -ry : ry);
  238. /* axes flipped? (by default y-axis is, due to libxmi's flipped-y
  239. convention) */
  240. x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
  241. y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
  242. /* location of `origin' (upper left corner of bounding rect. for
  243. ellipse) and width and height; libxmi's flipped-y convention
  244. affects these values */
  245. xorigin = IROUND(XD(pc.x - x_orientation * rx,
  246. pc.y - y_orientation * ry));
  247. yorigin = IROUND(YD(pc.x - x_orientation * rx,
  248. pc.y - y_orientation * ry));
  249. squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * rx, 0.0));
  250. squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * ry));
  251. /* Because this ellipse object was added to the path buffer, we
  252. already know that (1) the user->device frame map preserves
  253. coordinate axes, (2) effectively, angle == 0. These are
  254. necessary for the libxmi scan-conversion module to do the
  255. drawing. */
  256. /* draw ellipse (elliptic arc aligned with the coordinate axes, arc
  257. range = 64*360 64'ths of a degree) */
  258. _pl_i_draw_elliptic_arc_internal (R___(_plotter)
  259. xorigin, yorigin,
  260. squaresize_x, squaresize_y,
  261. 0, 64 * 360);
  262. }
  263. break;
  264. default: /* shouldn't happen */
  265. break;
  266. }
  267. }
  268. /* Use libxmi rendering to draw what would be a circular arc in the user
  269. frame. If this is called, the map from user to device coordinates is
  270. assumed to preserve coordinate axes (it may be anisotropic [x and y
  271. directions scaled differently], and it may include a reflection through
  272. either or both axes). So it will be a circular or elliptic arc in the
  273. device frame, of the sort that libxmi supports. */
  274. void
  275. _pl_i_draw_elliptic_arc (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
  276. {
  277. double radius;
  278. double theta0, theta1;
  279. int startangle, anglerange;
  280. int x_orientation, y_orientation;
  281. int xorigin, yorigin;
  282. unsigned int squaresize_x, squaresize_y;
  283. /* axes flipped? (by default y-axis is, due to xmi's flipped-y convention) */
  284. x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
  285. y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
  286. /* radius of circular arc in user frame is distance to p0, and also to p1 */
  287. radius = DIST(pc, p0);
  288. /* location of `origin' (upper left corner of bounding rect. on display)
  289. and width and height; X's flipped-y convention affects these values */
  290. xorigin = IROUND(XD(pc.x - x_orientation * radius,
  291. pc.y - y_orientation * radius));
  292. yorigin = IROUND(YD(pc.x - x_orientation * radius,
  293. pc.y - y_orientation * radius));
  294. squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * radius, 0.0));
  295. squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * radius));
  296. theta0 = _xatan2 (-y_orientation * (p0.y - pc.y),
  297. x_orientation * (p0.x - pc.x)) / M_PI;
  298. theta1 = _xatan2 (-y_orientation * (p1.y - pc.y),
  299. x_orientation * (p1.x - pc.x)) / M_PI;
  300. if (theta1 < theta0)
  301. theta1 += 2.0; /* adjust so that difference > 0 */
  302. if (theta0 < 0.0)
  303. {
  304. theta0 += 2.0; /* adjust so that startangle > 0 */
  305. theta1 += 2.0;
  306. }
  307. if (theta1 - theta0 > 1.0) /* swap if angle appear to be > 180 degrees */
  308. {
  309. double tmp;
  310. tmp = theta0;
  311. theta0 = theta1;
  312. theta1 = tmp;
  313. theta1 += 2.0; /* adjust so that difference > 0 */
  314. }
  315. if (theta0 >= 2.0 && theta1 >= 2.0)
  316. /* avoid obscure X bug */
  317. {
  318. theta0 -= 2.0;
  319. theta1 -= 2.0;
  320. }
  321. startangle = IROUND(64 * theta0 * 180.0); /* in 64'ths of a degree */
  322. anglerange = IROUND(64 * (theta1 - theta0) * 180.0); /* likewise */
  323. _pl_i_draw_elliptic_arc_internal (R___(_plotter)
  324. xorigin, yorigin,
  325. squaresize_x, squaresize_y,
  326. startangle, anglerange);
  327. }
  328. /* Use libxmi rendering to draw what would be a quarter-ellipse in the user
  329. frame. If this is called, the map from user to device coordinates is
  330. assumed to preserve coordinate axes (it may be anisotropic [x and y
  331. directions scaled differently], and it may include a reflection through
  332. either or both axes). So it will be a quarter-ellipse in the device
  333. frame, of the sort that libxmi supports. */
  334. void
  335. _pl_i_draw_elliptic_arc_2 (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
  336. {
  337. double rx, ry;
  338. double x0, y0, x1, y1, xc, yc;
  339. int startangle, endangle, anglerange;
  340. int x_orientation, y_orientation;
  341. int xorigin, yorigin;
  342. unsigned int squaresize_x, squaresize_y;
  343. /* axes flipped? (by default y-axis is, due to xmi's flipped-y convention) */
  344. x_orientation = (_plotter->drawstate->transform.m[0] >= 0 ? 1 : -1);
  345. y_orientation = (_plotter->drawstate->transform.m[3] >= 0 ? 1 : -1);
  346. xc = pc.x, yc = pc.y;
  347. x0 = p0.x, y0 = p0.y;
  348. x1 = p1.x, y1 = p1.y;
  349. if (y0 == yc && x1 == xc)
  350. /* initial pt. on x-axis, final pt. on y-axis */
  351. {
  352. /* semi-axes in user frame */
  353. rx = (x0 > xc) ? x0 - xc : xc - x0;
  354. ry = (y1 > yc) ? y1 - yc : yc - y1;
  355. /* starting and ending angles; note flipped-y convention */
  356. startangle = ((x0 > xc ? 1 : -1) * x_orientation == 1) ? 0 : 180;
  357. endangle = ((y1 > yc ? 1 : -1) * y_orientation == -1) ? 90 : 270;
  358. }
  359. else
  360. /* initial pt. on y-axis, final pt. on x-axis */
  361. {
  362. /* semi-axes in user frame */
  363. rx = (x1 > xc) ? x1 - xc : xc - x1;
  364. ry = (y0 > yc) ? y0 - yc : yc - y0;
  365. /* starting and ending angles; note flipped-y convention */
  366. startangle = ((y0 > yc ? 1 : -1) * y_orientation == -1) ? 90 : 270;
  367. endangle = ((x1 > xc ? 1 : -1) * x_orientation == 1) ? 0 : 180;
  368. }
  369. if (endangle < startangle)
  370. endangle += 360;
  371. anglerange = endangle - startangle; /* always 90 or 270 */
  372. /* our convention: a quarter-ellipse can only be 90 degrees
  373. of a libxmi ellipse, not 270 degrees, so interchange points */
  374. if (anglerange == 270)
  375. {
  376. int tmp;
  377. tmp = startangle;
  378. startangle = endangle;
  379. endangle = tmp;
  380. anglerange = 90;
  381. }
  382. if (startangle >= 360)
  383. /* avoid obscure libxmi bug */
  384. startangle -= 360; /* endangle no longer relevant */
  385. /* location of `origin' (upper left corner of bounding rect. on display)
  386. and width and height; xmi's flipped-y convention affects these values */
  387. xorigin = IROUND(XD(xc - x_orientation * rx,
  388. yc - y_orientation * ry));
  389. yorigin = IROUND(YD(xc - x_orientation * rx,
  390. yc - y_orientation * ry));
  391. squaresize_x = (unsigned int)IROUND(XDV(2 * x_orientation * rx, 0.0));
  392. squaresize_y = (unsigned int)IROUND(YDV(0.0, 2 * y_orientation * ry));
  393. /* reexpress in 64'ths of a degree (libxmi convention) */
  394. startangle *= 64;
  395. anglerange *= 64;
  396. _pl_i_draw_elliptic_arc_internal (R___(_plotter)
  397. xorigin, yorigin,
  398. squaresize_x, squaresize_y,
  399. startangle, anglerange);
  400. }
  401. /* Draw an elliptic arc aligned with the coordinate axes, by invoking a
  402. function in the libxmi API. Takes account of the possible need for
  403. filling.
  404. The cases squaresize_x = 0 and squaresize_y = 0 are handled specially,
  405. since miFillArcs() and miDrawArcs() do not support them. */
  406. void
  407. _pl_i_draw_elliptic_arc_internal (R___(Plotter *_plotter) int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange)
  408. {
  409. miGC *pGC;
  410. miArc arc;
  411. miPixel fgPixel, bgPixel;
  412. miPixel pixels[2];
  413. miPoint offset;
  414. /* determine background pixel color */
  415. bgPixel.type = MI_PIXEL_INDEX_TYPE;
  416. bgPixel.u.index = _plotter->drawstate->i_bg_color_index;
  417. pixels[0] = bgPixel;
  418. pixels[1] = bgPixel;
  419. /* construct an miGC (graphics context for the libxmi module); copy
  420. attributes from the Plotter's GC to it */
  421. pGC = miNewGC (2, pixels);
  422. _set_common_mi_attributes (_plotter->drawstate, pGC);
  423. /* libxmi's definition of an elliptic arc aligned with the axes */
  424. arc.x = xorigin;
  425. arc.y = yorigin;
  426. arc.width = squaresize_x;
  427. arc.height = squaresize_y;
  428. arc.angle1 = startangle;
  429. arc.angle2 = anglerange;
  430. if (_plotter->drawstate->fill_type)
  431. /* not transparent, so fill the arc */
  432. {
  433. /* set fg color in GC (and bg color too) */
  434. _pl_i_set_fill_color (S___(_plotter));
  435. fgPixel.type = MI_PIXEL_INDEX_TYPE;
  436. fgPixel.u.index = _plotter->drawstate->i_fill_color_index;
  437. pixels[0] = bgPixel;
  438. pixels[1] = fgPixel;
  439. miSetGCPixels (pGC, 2, pixels);
  440. /* fill the arc */
  441. if (squaresize_x <= 1 || squaresize_y <= 1)
  442. /* a special case, which miFillArcs() doesn't handle in the way we'd
  443. like; just paint a single pixel, irrespective of angle range */
  444. {
  445. miPoint point;
  446. point.x = xorigin;
  447. point.y = yorigin;
  448. miDrawPoints ((miPaintedSet *)_plotter->i_painted_set,
  449. pGC, MI_COORD_MODE_ORIGIN, 1, &point);
  450. }
  451. else
  452. /* default case */
  453. miFillArcs ((miPaintedSet *)_plotter->i_painted_set, pGC, 1, &arc);
  454. }
  455. if (_plotter->drawstate->pen_type)
  456. /* pen is present, so edge the arc */
  457. {
  458. unsigned int sp_size = 0; /* keep compiler happy */
  459. /* set fg color in GC (and bg color too) */
  460. _pl_i_set_pen_color (S___(_plotter));
  461. fgPixel.type = MI_PIXEL_INDEX_TYPE;
  462. fgPixel.u.index = _plotter->drawstate->i_pen_color_index;
  463. pixels[0] = bgPixel;
  464. pixels[1] = fgPixel;
  465. miSetGCPixels (pGC, 2, pixels);
  466. if (squaresize_x <= 1 || squaresize_y <= 1)
  467. /* Won't call miDrawArcs in the usual way, because it performs
  468. poorly when one of these two is zero, at least. Irrespective of
  469. angle range, will fill a disk of diameter equal to line width */
  470. {
  471. int sp_offset;
  472. sp_size
  473. = (unsigned int)_plotter->drawstate->quantized_device_line_width;
  474. sp_offset
  475. = (int)(_plotter->drawstate->quantized_device_line_width + 1) / 2;
  476. if (sp_size == 0)
  477. sp_size = 1;
  478. arc.x -= sp_offset;
  479. arc.y -= sp_offset;
  480. arc.width = sp_size;
  481. arc.height = sp_size;
  482. arc.angle1 = 0;
  483. arc.angle2 = 64 * 360;
  484. }
  485. /* edge the arc by invoking libxmi's reentrant arc-drawing function,
  486. passing it as final argument a pointer to persistent storage
  487. maintained by the Plotter */
  488. if (squaresize_x <= 1 || squaresize_y <= 1)
  489. /* miDrawArcs doesn't handle this case as we'd wish, will
  490. treat specially */
  491. {
  492. if (sp_size == 1)
  493. /* special subcase: line width is small too, so just paint a
  494. single pixel rather than filling abovementioned disk */
  495. {
  496. miPoint point;
  497. point.x = xorigin;
  498. point.y = yorigin;
  499. miDrawPoints ((miPaintedSet *)_plotter->i_painted_set,
  500. pGC, MI_COORD_MODE_ORIGIN, 1, &point);
  501. }
  502. else
  503. /* normal version of special case: draw filled disk of diameter
  504. equal to the line width, irrespective of the angle range */
  505. miFillArcs((miPaintedSet *)_plotter->i_painted_set, pGC, 1, &arc);
  506. }
  507. else
  508. /* default case, which is what is almost always used */
  509. miDrawArcs_r ((miPaintedSet *)_plotter->i_painted_set, pGC, 1, &arc,
  510. (miEllipseCache *)(_plotter->i_arc_cache_data));
  511. }
  512. /* deallocate miGC */
  513. miDeleteGC (pGC);
  514. /* copy from painted set to canvas, and clear */
  515. offset.x = 0;
  516. offset.y = 0;
  517. miCopyPaintedSetToCanvas ((miPaintedSet *)_plotter->i_painted_set,
  518. (miCanvas *)_plotter->i_canvas,
  519. offset);
  520. miClearPaintedSet ((miPaintedSet *)_plotter->i_painted_set);
  521. }
  522. bool
  523. _pl_i_paint_paths (S___(Plotter *_plotter))
  524. {
  525. return false;
  526. }