1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/widgets/img/lv_example_img_4.c
Gabor Kiss-Vamosi cbfbcb47f9 feat(color): use colors from material design
Use function instead of color macros
2021-02-23 15:03:06 +01:00

42 lines
1.1 KiB
C

#include "../../../lvgl.h"
#if LV_USE_IMG && LV_BUILD_EXAMPLES
static void ofs_y_anim(void * img, int32_t v)
{
lv_img_set_offset_y(img, v);
}
/**
* Image styling and offset
*/
void lv_example_img_4(void)
{
LV_IMG_DECLARE(img_skew_strip);
static lv_style_t style;
lv_style_init(&style);
lv_style_set_bg_color(&style, lv_color_yellow());
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_img_recolor_opa(&style, LV_OPA_COVER);
lv_style_set_img_recolor(&style, lv_color_black());
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
lv_obj_add_style(img, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_img_set_src(img, &img_skew_strip);
lv_obj_set_size(img, 150, 100);
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, img);
lv_anim_set_exec_cb(&a, ofs_y_anim);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_time(&a, 3000);
lv_anim_set_playback_time(&a, 500);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
}
#endif