1 #include "../lv_examples.h"
2 #if LV_BUILD_EXAMPLES
3 
4 #if LV_USE_DRAW_SW_COMPLEX_GRADIENTS
5 
6 /**
7  * Using radial gradient as background
8  */
lv_example_style_17(void)9 void lv_example_style_17(void)
10 {
11     static const lv_color_t grad_colors[2] = {
12         LV_COLOR_MAKE(0x9B, 0x18, 0x42),
13         LV_COLOR_MAKE(0x00, 0x00, 0x00),
14     };
15 
16     int32_t width = lv_display_get_horizontal_resolution(NULL);
17     int32_t height = lv_display_get_vertical_resolution(NULL);
18 
19     static lv_style_t style;
20     lv_style_init(&style);
21 
22     /*First define a color gradient. In this example we use a purple to black color map.*/
23     static lv_grad_dsc_t grad;
24 
25     lv_gradient_init_stops(&grad, grad_colors, NULL, NULL, sizeof(grad_colors) / sizeof(lv_color_t));
26 
27     /*Make a radial gradient with the center in the middle of the object, extending to the farthest corner*/
28     lv_grad_radial_init(&grad, LV_GRAD_CENTER, LV_GRAD_CENTER, LV_GRAD_RIGHT, LV_GRAD_BOTTOM, LV_GRAD_EXTEND_PAD);
29 
30     /*Set gradient as background*/
31     lv_style_set_bg_grad(&style, &grad);
32 
33     /*Create an object with the new style*/
34     lv_obj_t * obj = lv_obj_create(lv_screen_active());
35     lv_obj_add_style(obj, &style, 0);
36     lv_obj_set_size(obj, width, height);
37     lv_obj_center(obj);
38 }
39 
40 #else
41 
lv_example_style_17(void)42 void lv_example_style_17(void)
43 {
44     lv_obj_t * label = lv_label_create(lv_screen_active());
45     lv_obj_set_width(label, LV_PCT(80));
46     lv_label_set_text(label, "LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not enabled");
47     lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR);
48     lv_obj_center(label);
49 }
50 
51 #endif /*LV_USE_DRAW_SW_COMPLEX_GRADIENTS*/
52 
53 #endif /*LV_BUILD_EXAMPLES*/
54