FIX: drawLine added w to y instead of h

This commit is contained in:
Patrick Haßel 2025-01-25 22:06:35 +01:00
parent 9a6ca32976
commit 7fa66fb4d5

View File

@ -112,28 +112,25 @@ public:
void drawLine(int x0, int y0, int w, int h, const int thickness, const RGBA color) { void drawLine(int x0, int y0, int w, int h, const int thickness, const RGBA color) {
fixRect(x0, y0, w, h); fixRect(x0, y0, w, h);
if (h == 0) { for (auto t = 0; t < thickness; ++t) {
for (auto x = x0; x < x0 + w; ++x) { const auto offset = t % 2 == 0 ? t / 2 : -t / 2;
setPixel(x, y0, color); if (h == 0) {
} for (auto x = x0; x < x0 + w; ++x) {
} else if (w == 0) { setPixel(x, y0, color);
for (auto y = y0; y < y0 + w; ++y) { }
setPixel(x0, y, color); } else if (w == 0) {
} for (auto y = y0; y < y0 + h; ++y) {
} else if (w >= h) { setPixel(x0, y, color);
const auto m = static_cast<double>(h) / w; }
for (auto t = 0; t < thickness; ++t) { } else if (w >= h) {
const auto offset = t % 2 == 0 ? t / 2 : -t / 2; 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 t = 0; t < thickness; ++t) {
const auto offset = t % 2 == 0 ? t / 2 : -t / 2;
for (auto y = y0; y < y0 + w; ++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);
} }