mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 00:51:49 +08:00
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>
This commit is contained in:
@@ -12,13 +12,17 @@ void lv_example_style_2(void)
|
||||
|
||||
/*Make a gradient*/
|
||||
lv_style_set_bg_opa(&style, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));
|
||||
lv_style_set_bg_grad_color(&style, lv_palette_main(LV_PALETTE_BLUE));
|
||||
lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);
|
||||
static lv_gradient_t grad;
|
||||
grad.dir = LV_GRAD_DIR_VER;
|
||||
grad.stops_count = 2;
|
||||
grad.stops[0].color = lv_palette_lighten(LV_PALETTE_GREY, 1);
|
||||
grad.stops[1].color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
|
||||
/*Shift the gradient to the bottom*/
|
||||
lv_style_set_bg_main_stop(&style, 128);
|
||||
lv_style_set_bg_grad_stop(&style, 192);
|
||||
grad.stops[0].frac = 128;
|
||||
grad.stops[1].frac = 192;
|
||||
|
||||
lv_style_set_bg_gradient(&style, &grad);
|
||||
|
||||
/*Create an object with the new style*/
|
||||
lv_obj_t * obj = lv_obj_create(lv_scr_act());
|
||||
|
||||
@@ -11,9 +11,9 @@ void lv_example_canvas_1(void)
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.radius = 10;
|
||||
rect_dsc.bg_opa = LV_OPA_COVER;
|
||||
rect_dsc.bg_grad_dir = LV_GRAD_DIR_HOR;
|
||||
rect_dsc.bg_color = lv_palette_main(LV_PALETTE_RED);
|
||||
rect_dsc.bg_grad_color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
rect_dsc.bg_grad.dir = LV_GRAD_DIR_HOR;
|
||||
rect_dsc.bg_grad.stops[0].color = lv_palette_main(LV_PALETTE_RED);
|
||||
rect_dsc.bg_grad.stops[1].color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
rect_dsc.border_width = 2;
|
||||
rect_dsc.border_opa = LV_OPA_90;
|
||||
rect_dsc.border_color = lv_color_white();
|
||||
|
||||
@@ -6,9 +6,9 @@ rect_dsc = lv.draw_rect_dsc_t()
|
||||
rect_dsc.init()
|
||||
rect_dsc.radius = 10
|
||||
rect_dsc.bg_opa = lv.OPA.COVER
|
||||
rect_dsc.bg_grad_dir = lv.GRAD_DIR.HOR
|
||||
rect_dsc.bg_color = lv.palette_main(lv.PALETTE.RED)
|
||||
rect_dsc.bg_grad_color = lv.palette_main(lv.PALETTE.BLUE)
|
||||
rect_dsc.bg_grad.dir = lv.GRAD_DIR.HOR
|
||||
rect_dsc.bg_grad.stops[0].color = lv.palette_main(lv.PALETTE.RED)
|
||||
rect_dsc.bg_grad.stops[1].color = lv.palette_main(lv.PALETTE.BLUE)
|
||||
rect_dsc.border_width = 2
|
||||
rect_dsc.border_opa = lv.OPA._90
|
||||
rect_dsc.border_color = lv.color_white()
|
||||
|
||||
Reference in New Issue
Block a user