1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/examples/widgets/img/lv_example_img_4.c

42 lines
1.0 KiB
C
Raw Normal View History

2021-02-08 09:53:03 +01:00
#include "../../../lvgl.h"
2021-02-14 14:56:34 +01:00
#if LV_USE_IMG && LV_BUILD_EXAMPLES
2021-02-08 09:53:03 +01:00
2021-02-22 20:27:46 +01:00
static void ofs_y_anim(void * img, int32_t v)
{
lv_img_set_offset_y(img, v);
}
2021-02-08 09:53:03 +01:00
/**
* Image styling and offset
*/
void lv_example_img_4(void)
{
2021-02-19 18:19:32 +01:00
LV_IMG_DECLARE(img_skew_strip);
2021-02-08 09:53:03 +01:00
static lv_style_t style;
lv_style_init(&style);
lv_style_set_bg_color(&style, lv_color_yellow());
2021-02-08 09:53:03 +01:00
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());
2021-02-08 09:53:03 +01:00
lv_obj_t * img = lv_img_create(lv_scr_act());
2021-02-08 09:53:03 +01:00
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_center(img);
2021-02-08 09:53:03 +01:00
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, img);
2021-02-22 20:27:46 +01:00
lv_anim_set_exec_cb(&a, ofs_y_anim);
2021-02-08 09:53:03 +01:00
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