diff options
author | Mattias Andrée <maandree@kth.se> | 2023-02-08 22:32:35 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-02-08 22:32:35 +0100 |
commit | e9aafb9d4728d7b3806fb0866dc3927dd04691e2 (patch) | |
tree | 94c12ae6b8c87f6af3d330762d07f9292115fb8a | |
parent | Fix out of bounds error in drawing of vertical lines (diff) | |
download | librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-e9aafb9d4728d7b3806fb0866dc3927dd04691e2.tar.gz librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-e9aafb9d4728d7b3806fb0866dc3927dd04691e2.tar.bz2 librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-e9aafb9d4728d7b3806fb0866dc3927dd04691e2.tar.xz |
Fix warnings and infinite loop bug
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | draw_linear_bezier_reference.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/draw_linear_bezier_reference.c b/draw_linear_bezier_reference.c index 63a978f..dbfb87f 100644 --- a/draw_linear_bezier_reference.c +++ b/draw_linear_bezier_reference.c @@ -35,8 +35,8 @@ draw_linear_bezier_reference(RASTER *restrict raster, double x1, double y1, doub /* Find next vertical and next hozitonal grid line */ x = xdir < 0 ? floor(prevX) : xdir > 0 ? ceil(prevX) : prevX; y = ydir < 0 ? floor(prevY) : ydir > 0 ? ceil(prevY) : prevY; - x = x == prevX ? x + xdir : x; - y = y == prevY ? y + ydir : y; + x = iszeroish(x - prevX) ? x + xdir : x; + y = iszeroish(y - prevY) ? y + ydir : y; /* Limit to the extend of the drawn line segment */ if ((xdir < 0 && x < x2) || (xdir > 0 && x > x2)) @@ -540,13 +540,13 @@ check_random_line(double rand_xmin, double rand_xmax, double rand_ymin, double r if (!dy) continue; - hit = x >= floor(xmin) && x <= ceil(xmax); + hit = (double)x >= floor(xmin) && (double)x <= ceil(xmax); hit |= !x && xmin < 0; - hit &= y >= floor(ymin) && y <= ceil(ymax); + hit &= (double)y >= floor(ymin) && (double)y <= ceil(ymax); ASSERT(hit || !raster->cells[y * 10 + x].cell_coverage); - hit = x >= floor(xmin) && x <= ceil(xmax); - hit &= y >= floor(ymin) && y <= ceil(ymax); + hit = (double)x >= floor(xmin) && (double)x <= ceil(xmax); + hit &= (double)y >= floor(ymin) && (double)y <= ceil(ymax); if (!hit || !dx || !x) continue; |