From 422efce8a49ad2e95c8a1d200a9682b9782c98a5 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Tue, 24 Nov 2020 17:28:41 +0800 Subject: [PATCH] improve lcd_vgcanvas_fill_rect --- src/lcd/lcd_vgcanvas.inc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lcd/lcd_vgcanvas.inc b/src/lcd/lcd_vgcanvas.inc index 795d17639..22bda539b 100644 --- a/src/lcd/lcd_vgcanvas.inc +++ b/src/lcd/lcd_vgcanvas.inc @@ -111,19 +111,28 @@ static ret_t lcd_vgcanvas_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) vgcanvas_set_antialias(canvas, TRUE); vgcanvas_restore(canvas); } else if (w <= 1) { + vgcanvas_save(canvas); vgcanvas_begin_path(canvas); - vgcanvas_move_to(canvas, x + 0.5f, y); - vgcanvas_line_to(canvas, x + 0.5f, y + h); + vgcanvas_set_antialias(canvas, FALSE); + vgcanvas_translate(canvas, 0.5f, -0.5f); + vgcanvas_move_to(canvas, x, y); + vgcanvas_line_to(canvas, x, y + h); vgcanvas_set_line_width(canvas, 1); vgcanvas_set_stroke_color(canvas, lcd->fill_color); vgcanvas_stroke(canvas); + vgcanvas_set_antialias(canvas, TRUE); + vgcanvas_restore(canvas); } else if (h <= 1) { + vgcanvas_save(canvas); vgcanvas_begin_path(canvas); - vgcanvas_move_to(canvas, x, y + 0.5f); - vgcanvas_line_to(canvas, x + w, y + 0.5f); + vgcanvas_set_antialias(canvas, FALSE); + vgcanvas_move_to(canvas, x, y); + vgcanvas_line_to(canvas, x + w, y); vgcanvas_set_line_width(canvas, 1); vgcanvas_set_stroke_color(canvas, lcd->fill_color); vgcanvas_stroke(canvas); + vgcanvas_set_antialias(canvas, TRUE); + vgcanvas_restore(canvas); } return RET_OK;