From: Matthew Fernandez Date: Wed, 24 Aug 2022 04:10:10 +0000 (-0700) Subject: use 'agxbprint' to round points instead of casting in 'Show_boxes' X-Git-Tag: 6.0.1~24^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd64fee8849995dc8a5292eaf78f67c13416d6a4;p=graphviz use 'agxbprint' to round points instead of casting in 'Show_boxes' This has the advantage of avoiding relying on values fitting in the range of an int. Going through C stdio this way, the full range of doubles can be preserved. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a70214fe..259669a9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Breaking**: libxdot fields for the size and number of operations, the statistics counts, and polygon line points are now `size_t` values instead of `int` values +- Accuracy of the bounding boxes printed by the `showboxes` feature have been + improved. ### Removed diff --git a/lib/common/routespl.c b/lib/common/routespl.c index ecb606fcf..e9a228434 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -39,8 +39,7 @@ static void printboxes(int boxn, boxf* boxes) for (bi = 0; bi < boxn; bi++) { ll = boxes[bi].LL, ur = boxes[bi].UR; agxbuf buf = {0}; - agxbprint(&buf, "%d %d %d %d pathbox", (int)ll.x, (int)ll.y, - (int)ur.x, (int)ur.y); + agxbprint(&buf, "%.0f %.0f %.0f %.0f pathbox", ll.x, ll.y, ur.x, ur.y); Show_boxes[bi + 1 + Show_cnt] = agxbdisown(&buf); } Show_cnt = newcnt; @@ -166,13 +165,13 @@ static void psprintboxes(int boxn, boxf* boxes) for (bi = 0; bi < boxn; bi++) { ll = boxes[bi].LL, ur = boxes[bi].UR; agxbuf buf = {0}; - agxbprint(&buf, "newpath\n%d %d moveto", (int)ll.x, (int)ll.y); + agxbprint(&buf, "newpath\n%.0f %.0f moveto", ll.x, ll.y); Show_boxes[li++] = agxbdisown(&buf); - agxbprint(&buf, "%d %d lineto", (int)ll.x, (int)ur.y); + agxbprint(&buf, "%.0f %.0f lineto", ll.x, ur.y); Show_boxes[li++] = agxbdisown(&buf); - agxbprint(&buf, "%d %d lineto", (int)ur.x, (int)ur.y); + agxbprint(&buf, "%.0f %.0f lineto", ur.x, ur.y); Show_boxes[li++] = agxbdisown(&buf); - agxbprint(&buf, "%d %d lineto", (int)ur.x, (int)ll.y); + agxbprint(&buf, "%.0f %.0f lineto", ur.x, ll.y); Show_boxes[li++] = agxbdisown(&buf); Show_boxes[li++] = strdup ("closepath stroke"); }