diff --git a/src/patrix/display/Display.h b/src/patrix/display/Display.h index 5d7ee58..0250198 100644 --- a/src/patrix/display/Display.h +++ b/src/patrix/display/Display.h @@ -112,28 +112,25 @@ public: void drawLine(int x0, int y0, int w, int h, const int thickness, const RGBA color) { fixRect(x0, y0, w, h); - if (h == 0) { - for (auto x = x0; x < x0 + w; ++x) { - setPixel(x, y0, color); - } - } else if (w == 0) { - for (auto y = y0; y < y0 + w; ++y) { - setPixel(x0, y, color); - } - } else if (w >= h) { - const auto m = static_cast(h) / w; - for (auto t = 0; t < thickness; ++t) { - const auto offset = t % 2 == 0 ? t / 2 : -t / 2; + for (auto t = 0; t < thickness; ++t) { + const auto offset = t % 2 == 0 ? t / 2 : -t / 2; + if (h == 0) { + for (auto x = x0; x < x0 + w; ++x) { + setPixel(x, y0, color); + } + } else if (w == 0) { + for (auto y = y0; y < y0 + h; ++y) { + setPixel(x0, y, color); + } + } else if (w >= h) { + const auto m = static_cast(h) / w; for (auto x = x0; x < x0 + w; ++x) { const auto y = static_cast(round(offset + x * m)); setPixel(x, y, color); } - } - } else { - const auto m = static_cast(w) / h; - 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) { + } else { + const auto m = static_cast(w) / h; + for (auto y = y0; y < y0 + h; ++y) { const auto x = static_cast(round(offset + y * m)); setPixel(x, y, color); }