1 #include "../lv_examples.h" 2 #if LV_BUILD_EXAMPLES 3 4 /** 5 * Using the background style properties 6 */ lv_example_style_2(void)7void 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[1].color = lv_palette_main(LV_PALETTE_BLUE); 20 21 /*Shift the gradient to the bottom*/ 22 grad.stops[0].frac = 128; 23 grad.stops[1].frac = 192; 24 25 lv_style_set_bg_grad(&style, &grad); 26 27 /*Create an object with the new style*/ 28 lv_obj_t * obj = lv_obj_create(lv_scr_act()); 29 lv_obj_add_style(obj, &style, 0); 30 lv_obj_center(obj); 31 } 32 33 #endif 34