From 2a25ddd0a258f8068c3e8b23555b065eb6de4452 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 5 Nov 2019 06:29:53 +0100 Subject: [PATCH] add lv_draw_px --- src/lv_draw/lv_draw_rect.c | 32 ++++++++++++++++++++++++++++++++ src/lv_draw/lv_draw_rect.h | 9 +++++++++ 2 files changed, 41 insertions(+) diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index c042d6b8b..9d8b200a5 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -61,6 +61,38 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_sty draw_border(coords, clip, style, opa_scale); } +/** + * Draw a pixel + * @param point the coordinates of the point to draw + * @param mask the pixel will be drawn only in this mask + * @param style pointer to a style + * @param opa_scale scale down the opacity by the factor + */ +void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style, lv_opa_t opa_scale) +{ + lv_opa_t opa = style->body.opa; + if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8; + + if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; + + lv_area_t fill_area; + fill_area.x1 = point->x; + fill_area.y1 = point->y; + fill_area.x2 = point->x; + fill_area.y2 = point->y; + + uint8_t mask_cnt = lv_draw_mask_get_cnt(); + + if(mask_cnt == 0) { + lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode); + } else { + uint8_t mask_buf; + lv_draw_mask_res_t mask_res; + mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1); + lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode); + } +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 852b72912..e3007addf 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -36,6 +36,15 @@ extern "C" { */ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); +/** + * Draw a pixel + * @param point the coordinates of the point to draw + * @param mask the pixel will be drawn only in this mask + * @param style pointer to a style + * @param opa_scale scale down the opacity by the factor + */ +void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style, lv_opa_t opa_scale); + /********************** * MACROS **********************/