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 19:01:40 +01:00
|
|
|
static void set_angle(void * img, int32_t v)
|
2021-02-22 11:23:24 +01:00
|
|
|
{
|
|
|
|
lv_img_set_angle(img, v);
|
|
|
|
}
|
|
|
|
|
2021-02-22 19:01:40 +01:00
|
|
|
static void set_zoom(void * img, int32_t v)
|
2021-02-22 11:23:24 +01:00
|
|
|
{
|
|
|
|
lv_img_set_zoom(img, v);
|
|
|
|
}
|
|
|
|
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show transformations (zoom and rotation) using a pivot point.
|
|
|
|
*/
|
|
|
|
void lv_example_img_3(void)
|
|
|
|
{
|
2021-02-19 18:19:32 +01:00
|
|
|
LV_IMG_DECLARE(img_cogwheel_argb);
|
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Now create the actual image*/
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * img = lv_img_create(lv_scr_act());
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_img_set_src(img, &img_cogwheel_argb);
|
|
|
|
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 50, 50);
|
|
|
|
lv_img_set_pivot(img, 0, 0); /*Rotate around the top left corner*/
|
|
|
|
|
|
|
|
lv_anim_t a;
|
|
|
|
lv_anim_init(&a);
|
|
|
|
lv_anim_set_var(&a, img);
|
2021-02-22 11:23:24 +01:00
|
|
|
lv_anim_set_exec_cb(&a, set_angle);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_anim_set_values(&a, 0, 3600);
|
|
|
|
lv_anim_set_time(&a, 5000);
|
|
|
|
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
|
|
|
|
lv_anim_start(&a);
|
|
|
|
|
2021-02-22 11:23:24 +01:00
|
|
|
lv_anim_set_exec_cb(&a, set_zoom);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_anim_set_values(&a, 128, 256);
|
|
|
|
lv_anim_set_playback_time(&a, 3000);
|
|
|
|
lv_anim_start(&a);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|