altos/draw: Check for horiz/vert line when clipping
authorKeith Packard <keithp@keithp.com>
Mon, 27 Feb 2023 02:46:40 +0000 (18:46 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 27 Feb 2023 02:46:40 +0000 (18:46 -0800)
Horizontal or vertical lines won't step along the minor axis while
clipping.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/draw/ao_line.c

index 832a916c76aed9dbe1042f7a024febe071ae93c6..7aa3662d3e4b14f661d30710c758d3c1e2abde15 100644 (file)
@@ -211,16 +211,20 @@ ao_clip_line(struct ao_cc *c, struct ao_cbox *b)
         */
        int32_t adj_min;
 
-       if (!c->first)
-               adj_min = div_ceil(c->e + adjust_major * c->e1, -c->e3);
-       else
-               adj_min = div_floor_plus_one(c->e + adjust_major * c->e1, -c->e3);
+       if (c->e3) {
+               if (!c->first)
+                       adj_min = div_ceil(c->e + adjust_major * c->e1, -c->e3);
+               else
+                       adj_min = div_floor_plus_one(c->e + adjust_major * c->e1, -c->e3);
+       }
 
        if (adj_min < adjust_minor) {
-               if (c->first)
-                       adjust_major = div_ceil(c->e - adjust_minor * c->e3, c->e1);
-               else
-                       adjust_major = div_floor_plus_one(c->e - adjust_minor * c->e3, c->e1);
+               if (c->e1) {
+                       if (c->first)
+                               adjust_major = div_ceil(c->e - adjust_minor * c->e3, c->e1);
+                       else
+                               adjust_major = div_floor_plus_one(c->e - adjust_minor * c->e3, c->e1);
+               }
        } else {
                adjust_minor = adj_min;
        }