2021-04-08 13:07:48 +02:00
|
|
|
#include "../lv_examples.h"
|
2021-02-19 14:47:32 +01:00
|
|
|
#if LV_BUILD_EXAMPLES
|
|
|
|
|
|
|
|
/**
|
2021-05-27 11:50:04 +02:00
|
|
|
* Using the background style properties
|
2021-02-19 14:47:32 +01:00
|
|
|
*/
|
|
|
|
void lv_example_style_2(void)
|
|
|
|
{
|
|
|
|
static lv_style_t style;
|
|
|
|
lv_style_init(&style);
|
2021-05-27 11:50:04 +02:00
|
|
|
lv_style_set_radius(&style, 5);
|
2021-02-19 14:47:32 +01:00
|
|
|
|
2021-05-27 11:50:04 +02:00
|
|
|
/*Make a gradient*/
|
2021-02-19 14:47:32 +01:00
|
|
|
lv_style_set_bg_opa(&style, LV_OPA_COVER);
|
2022-01-11 12:38:30 +01:00
|
|
|
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);
|
2021-02-19 14:47:32 +01:00
|
|
|
|
2021-05-27 11:50:04 +02:00
|
|
|
/*Shift the gradient to the bottom*/
|
2022-01-11 12:38:30 +01:00
|
|
|
grad.stops[0].frac = 128;
|
|
|
|
grad.stops[1].frac = 192;
|
|
|
|
|
|
|
|
lv_style_set_bg_gradient(&style, &grad);
|
2021-02-19 14:47:32 +01:00
|
|
|
|
|
|
|
/*Create an object with the new style*/
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * obj = lv_obj_create(lv_scr_act());
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_add_style(obj, &style, 0);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_center(obj);
|
2021-02-19 14:47:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|