]> granicus.if.org Git - graphviz/commitdiff
use 'agxbprint' to round points instead of casting in 'Show_boxes'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 24 Aug 2022 04:10:10 +0000 (21:10 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 26 Aug 2022 14:55:55 +0000 (07:55 -0700)
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.

CHANGELOG.md
lib/common/routespl.c

index 3a70214fe73c14ab34074e18d059c44cdcbf2f94..259669a9f067edb042218c07a442493e6c31903e 100644 (file)
@@ -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
 
index ecb606fcf7aaf472ed547488d39f333cedfbcfaa..e9a22843475cfc83a9bf2dc4e093cea37301fdd8 100644 (file)
@@ -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");
     }