From 014a08cabb856b2360419aac404744029ee4748c Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 15 Mar 2012 22:50:17 +1100 Subject: skin_engine: New tag to draw a rectangle (optionally with a gradient) %dr(x, y, width, height, [colour1[, colour2]]): x,y - viewport relative pixel coordinates to start the rectangle. width, height - obvious. can be '-' to fill the viewport if both colours are left out the viewports foreground colour will be used if one colour is specified it will fill the rectangle that colour. if both colours are specified it will gradient fill the rectangle. Change-Id: Iad451e99ded663bc7c5d182443659db7d909b388 --- firmware/drivers/lcd-bitmap-common.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 80796b392b..0bae790e58 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -41,14 +41,18 @@ #endif #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) -void lcd_gradient_fillrect(int x1, int x2, int y1, int y2, +void lcd_gradient_fillrect(int x, int y, int width, int height, unsigned start_rgb, unsigned end_rgb) { int old_pattern = current_vp->fg_pattern; int step_mul, i; - if (y2 - y1 == 0) return; + int x1, x2; + x1 = x; + x2 = x + width; + + if (height == 0) return; - step_mul = (1 << 16) / (y2 - y1); + step_mul = (1 << 16) / height; int h_r = RGB_UNPACK_RED(start_rgb); int h_g = RGB_UNPACK_GREEN(start_rgb); int h_b = RGB_UNPACK_BLUE(start_rgb); @@ -59,7 +63,7 @@ void lcd_gradient_fillrect(int x1, int x2, int y1, int y2, h_g = (h_g << 16) + (1 << 15); h_b = (h_b << 16) + (1 << 15); - for(i = y1; i < y2; i++) { + for(i = y; i < y + height; i++) { current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); lcd_hline(x1, x2, i); h_r -= rstep; @@ -108,7 +112,7 @@ static void lcd_do_gradient_line(int x1, int x2, int y, unsigned h, h_g -= h * gstep; h_b -= h * bstep; end_rgb = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); - lcd_gradient_fillrect(x1, x2, y, y + h, start_rgb, end_rgb); + lcd_gradient_fillrect(x1, y, x2 - x1, h, start_rgb, end_rgb); } #endif -- cgit v1.2.3