1 #include "../lv_examples.h"
2 #if LV_BUILD_EXAMPLES
3 
4 /**
5  * Using the background style properties
6  */
lv_example_style_2(void)7 void lv_example_style_2(void)
8 {
9     static lv_style_t style;
10     lv_style_init(&style);
11     lv_style_set_radius(&style, 5);
12 
13     /*Make a gradient*/
14     lv_style_set_bg_opa(&style, LV_OPA_COVER);
15     static lv_grad_dsc_t grad;
16     grad.dir = LV_GRAD_DIR_VER;
17     grad.stops_count = 2;
18     grad.stops[0].color = lv_palette_lighten(LV_PALETTE_GREY, 1);
19     grad.stops[0].opa = LV_OPA_COVER;
20     grad.stops[1].color = lv_palette_main(LV_PALETTE_BLUE);
21     grad.stops[1].opa = LV_OPA_COVER;
22 
23     /*Shift the gradient to the bottom*/
24     grad.stops[0].frac  = 128;
25     grad.stops[1].frac  = 192;
26 
27     lv_style_set_bg_grad(&style, &grad);
28 
29     /*Create an object with the new style*/
30     lv_obj_t * obj = lv_obj_create(lv_screen_active());
31     lv_obj_add_style(obj, &style, 0);
32     lv_obj_center(obj);
33 }
34 
35 #endif
36