Merge pull request #2790 from kwagyeman/kwabena/fix_draw_line
Some checks failed
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Has been cancelled
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Has been cancelled
🔥 Firmware Build / build-firmware (DOCKER) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV2) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV3) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV4) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Has been cancelled
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Has been cancelled
🔥 Firmware Build / code-size-report (push) Has been cancelled
🔥 Firmware Build / stable-release (push) Has been cancelled
🔥 Firmware Build / development-release (push) Has been cancelled

lib/imlib: Fix draw line glitch.
This commit is contained in:
Ibrahim Abdelkader 2025-07-29 11:16:52 +03:00 committed by GitHub
commit 718b4b80a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -211,6 +211,7 @@ void imlib_draw_line(image_t *img, int x0, int y0, int x1, int y1, int c, int th
// steep line // steep line
x1 = (e2 + th / 2) / dy; // start offset x1 = (e2 + th / 2) / dy; // start offset
int err = x1 * dy - th / 2; // shift error value to offset width int err = x1 * dy - th / 2; // shift error value to offset width
err = IM_MAX(err, 0); // prevent negative error on straight line
for (x0 -= x1 * sx;; y0 += sy) { for (x0 -= x1 * sx;; y0 += sy) {
x1 = x0; x1 = x0;
imlib_set_pixel_aa(img, x1, y0, err, c); // aliasing pre-pixel imlib_set_pixel_aa(img, x1, y0, err, c); // aliasing pre-pixel
@ -232,6 +233,7 @@ void imlib_draw_line(image_t *img, int x0, int y0, int x1, int y1, int c, int th
// flat line // flat line
y1 = (e2 + th / 2) / dx; // start offset y1 = (e2 + th / 2) / dx; // start offset
int err = y1 * dx - th / 2; // shift error value to offset width int err = y1 * dx - th / 2; // shift error value to offset width
err = IM_MAX(err, 0); // prevent negative error on straight line
for (y0 -= y1 * sy;; x0 += sx) { for (y0 -= y1 * sy;; x0 += sx) {
y1 = y0; y1 = y0;
imlib_set_pixel_aa(img, x0, y1, err, c); // aliasing pre-pixel imlib_set_pixel_aa(img, x0, y1, err, c); // aliasing pre-pixel