lv_example_style_2.c 824 B

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