From 09602387b285b1d729b28561b26a07397a8d7d6f Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Fri, 9 Oct 2020 13:56:28 +0200 Subject: [PATCH] graphics_rgb565.c: Implement drawing empty rectangles --- openrtx/include/interfaces/graphics.h | 2 +- openrtx/src/graphics/graphics_rgb565.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openrtx/include/interfaces/graphics.h b/openrtx/include/interfaces/graphics.h index d040ae77..75e5cf07 100644 --- a/openrtx/include/interfaces/graphics.h +++ b/openrtx/include/interfaces/graphics.h @@ -152,7 +152,7 @@ void graphics_drawLine(point_t start, point_t end, color_t color); * @param width: rectangle width, in pixels, borders included. * @param height: rectangle height, in pixels, borders included. * @param color: border and fill color, in color_t format. - * @param fill: if true the rectangle will be solid, otherwise it will have a 1-pixel border + * @param fill: if true the rectangle will be solid, otherwise it will be empty with a 1-pixel border */ void graphics_drawRect(point_t start, uint16_t width, uint16_t height, color_t color, bool fill); diff --git a/openrtx/src/graphics/graphics_rgb565.c b/openrtx/src/graphics/graphics_rgb565.c index 1fb8c821..4f01ea09 100644 --- a/openrtx/src/graphics/graphics_rgb565.c +++ b/openrtx/src/graphics/graphics_rgb565.c @@ -136,13 +136,17 @@ void graphics_drawRect(point_t start, uint16_t width, uint16_t height, color_t c rgb565_t color_565 = _true2highColor(color); uint16_t x_max = start.x + width; uint16_t y_max = start.y + height; + bool perimeter = 0; if(x_max > (screen_width - 1)) x_max = screen_width - 1; if(y_max > (screen_height - 1)) y_max = screen_height - 1; for(int y=start.y; y < y_max; y++) { for(int x=start.x; x < x_max; x++) { - buf[x + y*screen_width] = color_565; + if(y == start.y || y == y_max-1 || x == start.x || x == x_max-1) perimeter = 1; + else perimeter = 0; + // If fill is false, draw only rectangle perimeter + if(fill || perimeter) buf[x + y*screen_width] = color_565; } } }