From ea162d215853381557a55f682d5035b9b2aadd33 Mon Sep 17 00:00:00 2001 From: Alessandro Apostoli <30294218+yaapu@users.noreply.github.com> Date: Sun, 15 Jan 2023 02:50:44 +0100 Subject: [PATCH] fix(lua): fix drawHudRectangle for roll = 0 (#2978) - fixed an extra line at the bottom of the hud rectangle - fixed overflowing hud rectangle for horizon outside viewport (pitch > 0) --- radio/src/lua/api_colorlcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/lua/api_colorlcd.cpp b/radio/src/lua/api_colorlcd.cpp index 57d60657c..b853008a5 100644 --- a/radio/src/lua/api_colorlcd.cpp +++ b/radio/src/lua/api_colorlcd.cpp @@ -1331,7 +1331,7 @@ static void drawHudRectangle(BitmapBuffer * dc, float pitch, float roll, coord_t if (roll == 0.0f) { // prevent divide by zero dc->drawSolidFilledRect( xmin, max(ymin, ymin + (ywidth/2 + (coord_t)dy)), - xmax - xmin, min(ywidth, ywidth/2 - (coord_t)dy + (dy != 0.0f ? 1 : 0)), flags); + xmax - xmin, max(0,min(ywidth, ywidth/2 - (coord_t)dy)), flags); } else if (fabs(roll) >= 180.0f) { dc->drawSolidFilledRect(xmin, ymin, xmax - xmin, min(ywidth, ywidth/2 + (coord_t)fabsf(dy)), flags);