1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00
lvgl/examples/widgets/image/lv_example_image_3.c
lhdjply d939316e26
chore(api_map): remove unused api and repalce error name api (#5367)
Signed-off-by: lhdjply <lhdjply@126.com>
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2024-01-18 20:30:39 +08:00

43 lines
1.0 KiB
C

#include "../../lv_examples.h"
#if LV_USE_IMAGE && LV_BUILD_EXAMPLES
static void set_angle(void * img, int32_t v)
{
lv_image_set_rotation(img, v);
}
static void set_scale(void * img, int32_t v)
{
lv_image_set_scale(img, v);
}
/**
* Show transformations (zoom and rotation) using a pivot point.
*/
void lv_example_image_3(void)
{
LV_IMAGE_DECLARE(img_cogwheel_argb);
/*Now create the actual image*/
lv_obj_t * img = lv_image_create(lv_screen_active());
lv_image_set_src(img, &img_cogwheel_argb);
lv_obj_align(img, LV_ALIGN_CENTER, 50, 50);
lv_image_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);
lv_anim_set_exec_cb(&a, set_angle);
lv_anim_set_values(&a, 0, 3600);
lv_anim_set_duration(&a, 5000);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
lv_anim_set_exec_cb(&a, set_scale);
lv_anim_set_values(&a, 128, 256);
lv_anim_set_playback_duration(&a, 3000);
lv_anim_start(&a);
}
#endif