|
@@ -566,18 +566,10 @@ OLIVECDEF void olivec_line(Olivec_Canvas oc, int x1, int y1, int x2, int y2, uin
|
|
|
OLIVEC_SWAP(int, y1, y2);
|
|
|
}
|
|
|
|
|
|
- // Cull out invisible line
|
|
|
- if (x1 > (int) oc.width) return;
|
|
|
- if (x2 < 0) return;
|
|
|
-
|
|
|
- // Clamp the line to the boundaries
|
|
|
- if (x1 < 0) x1 = 0;
|
|
|
- if (x2 >= (int) oc.width) x2 = (int) oc.width - 1;
|
|
|
-
|
|
|
for (int x = x1; x <= x2; ++x) {
|
|
|
int y = dy*(x - x1)/dx + y1;
|
|
|
// TODO: move boundary checks out side of the loops in olivec_draw_line
|
|
|
- if (0 <= y && y < (int) oc.height) {
|
|
|
+ if (0 <= x && x < (int) oc.width && 0 <= y && y < (int) oc.height) {
|
|
|
olivec_blend_color(&OLIVEC_PIXEL(oc, x, y), color);
|
|
|
}
|
|
|
}
|
|
@@ -587,18 +579,10 @@ OLIVECDEF void olivec_line(Olivec_Canvas oc, int x1, int y1, int x2, int y2, uin
|
|
|
OLIVEC_SWAP(int, y1, y2);
|
|
|
}
|
|
|
|
|
|
- // Cull out invisible line
|
|
|
- if (y1 > (int) oc.height) return;
|
|
|
- if (y2 < 0) return;
|
|
|
-
|
|
|
- // Clamp the line to the boundaries
|
|
|
- if (y1 < 0) y1 = 0;
|
|
|
- if (y2 >= (int) oc.height) y2 = (int) oc.height - 1;
|
|
|
-
|
|
|
for (int y = y1; y <= y2; ++y) {
|
|
|
int x = dx*(y - y1)/dy + x1;
|
|
|
// TODO: move boundary checks out side of the loops in olivec_draw_line
|
|
|
- if (0 <= x && x < (int) oc.width) {
|
|
|
+ if (0 <= x && x < (int) oc.width && 0 <= y && y < (int) oc.height) {
|
|
|
olivec_blend_color(&OLIVEC_PIXEL(oc, x, y), color);
|
|
|
}
|
|
|
}
|