FIX: drawLine last pixel has not been printed

This commit is contained in:
Patrick Haßel 2025-01-25 22:19:44 +01:00
parent 03d6899817
commit 2b61f7ae98

View File

@ -115,22 +115,22 @@ public:
for (auto t = 0; t < thickness; ++t) { for (auto t = 0; t < thickness; ++t) {
const auto offset = t % 2 == 0 ? t / 2 : -t / 2; const auto offset = t % 2 == 0 ? t / 2 : -t / 2;
if (h == 0) { if (h == 0) {
for (auto x = x0; x < x0 + w; ++x) { for (auto x = x0; x <= x0 + w; ++x) {
setPixel(x, y0, color); setPixel(x, y0, color);
} }
} else if (w == 0) { } else if (w == 0) {
for (auto y = y0; y < y0 + h; ++y) { for (auto y = y0; y <= y0 + h; ++y) {
setPixel(x0, y, color); setPixel(x0, y, color);
} }
} else if (w >= h) { } else if (w >= h) {
const auto m = static_cast<double>(h) / w; const auto m = static_cast<double>(h) / w;
for (auto x = x0; x < x0 + w; ++x) { for (auto x = x0; x <= x0 + w; ++x) {
const auto y = static_cast<int>(round(offset + x * m)); const auto y = static_cast<int>(round(offset + x * m));
setPixel(x, y, color); setPixel(x, y, color);
} }
} else { } else {
const auto m = static_cast<double>(w) / h; const auto m = static_cast<double>(w) / h;
for (auto y = y0; y < y0 + h; ++y) { for (auto y = y0; y <= y0 + h; ++y) {
const auto x = static_cast<int>(round(offset + y * m)); const auto x = static_cast<int>(round(offset + y * m));
setPixel(x, y, color); setPixel(x, y, color);
} }