Files
lvgl/src/draw/lv_draw_rect.c
X-Ryl669 6617385f8a feat(draw): add gradient dithering support (#2872)
* Add dithering to gradients

* Add support for 8x8 matrix for ordered dithering

* Fix CI errors

* Try error diffusion on vertical gradient too

* Vertical error diffusion dithering

* Add support for runtime based dithering mode selection (from none, ordered, error diffusion).

* Reduce the binary size of the code by sharing the dithering table when appropriate.

* Fix CI

* Fix CI

* Review corrections

* Fix union mapping

* Revert bg_color changes

* Fix for keeping bg_color in the API.

* Fix after review

* Add support for setting multiple stops per gradient in the style API

* Let's make an example

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2022-01-11 12:38:30 +01:00

76 lines
1.8 KiB
C

/**
* @file lv_draw_rect.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
#include "lv_draw_rect.h"
#include "../misc/lv_assert.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
{
lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t));
dsc->bg_color = lv_color_white();
#if __STDC_VERSION__ < 201112L
dsc->bg_grad.stops[0].color = lv_color_white();
#endif
dsc->bg_grad.stops[1].color = lv_color_black();
dsc->bg_grad.stops[1].frac = 0xFF;
dsc->bg_grad.stops_count = 2;
dsc->border_color = lv_color_black();
dsc->shadow_color = lv_color_black();
dsc->bg_img_symbol_font = LV_FONT_DEFAULT;
dsc->bg_opa = LV_OPA_COVER;
dsc->bg_img_opa = LV_OPA_COVER;
dsc->outline_opa = LV_OPA_COVER;
dsc->border_opa = LV_OPA_COVER;
dsc->shadow_opa = LV_OPA_COVER;
dsc->border_side = LV_BORDER_SIDE_FULL;
}
/**
* Draw a rectangle
* @param coords the coordinates of the rectangle
* @param mask the rectangle will be drawn only in this mask
* @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)
{
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
draw_ctx->draw_rect(draw_ctx, dsc, coords);
LV_ASSERT_MEM_INTEGRITY();
}
/**********************
* STATIC FUNCTIONS
**********************/