feat(lottie): add ThorVG based lottie widget

This commit is contained in:
Gabor Kiss-Vamosi
2024-05-13 18:00:31 +02:00
parent f34ec4b671
commit 9c5ca0e081
25 changed files with 805 additions and 5 deletions
+11
View File
@@ -0,0 +1,11 @@
Load a Lottie animation from an array
-------------------------------------
.. lv_example:: libs/lottie/lv_example_lottie_1
:language: c
Load a Lottie animation from file
---------------------------------
.. lv_example:: libs/lottie/lv_example_lottie_2
:language: c
@@ -0,0 +1,43 @@
#include "../../lv_examples.h"
#if LV_BUILD_EXAMPLES
#if LV_USE_LOTTIE
/**
* Load an lottie animation from data
*/
void lv_example_lottie_1(void)
{
extern const uint8_t lv_example_lottie_approve[];
extern const size_t lv_example_lottie_approve_size;
lv_obj_t * lottie = lv_lottie_create(lv_screen_active());
lv_lottie_set_src_data(lottie, lv_example_lottie_approve, lv_example_lottie_approve_size);
#if LV_DRAW_BUF_ALIGN == 4 && LV_DRAW_BUF_STRIDE_ALIGN == 1
/*If there are no special requirements, just declare a buffer
x4 because the Lottie is rendered in ARGB8888 format*/
static uint8_t buf[64 * 64 * 4];
lv_lottie_set_buffer(lottie, 64, 64, buf);
#else
/*For GPUs and special alignemnt/strid setting use a draw_buf instead*/
LV_DRAW_BUF_DEFINE(draw_buf, 64, 64, LV_COLOR_FORMAT_ARGB8888);
lv_lottie_set_draw_buf(lottie, &draw_buf);
#endif
lv_obj_center(lottie);
}
#else
void lv_example_lottie_1(void)
{
/*fallback for online examples*/
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Lottie cannot be previewed online");
lv_obj_center(label);
}
#endif /*LV_USE_LOTTIE*/
#endif /*LV_BUILD_EXAMPLES*/
@@ -0,0 +1,41 @@
#include "../../lv_examples.h"
#if LV_BUILD_EXAMPLES
#if LV_USE_LOTTIE
/**
* Load an lottie animation from file
*/
void lv_example_lottie_2(void)
{
lv_obj_t * lottie = lv_lottie_create(lv_screen_active());
lv_lottie_set_src_file(lottie, "lvgl/examples/widgets/lottie/lv_example_lottie_approve.json");
#if LV_DRAW_BUF_ALIGN == 4 && LV_DRAW_BUF_STRIDE_ALIGN == 1
/*If there are no special requirements, just declare a buffer
x4 because the Lottie is rendered in ARGB8888 format*/
static uint8_t buf[64 * 64 * 4];
lv_lottie_set_buffer(lottie, 64, 64, buf);
#else
/*For GPUs and special alignemnt/strid setting use a draw_buf instead*/
LV_DRAW_BUF_DEFINE(draw_buf, 64, 64, LV_COLOR_FORMAT_ARGB8888);
lv_lottie_set_draw_buf(lottie, &draw_buf);
#endif
lv_obj_center(lottie);
}
#else
void lv_example_lottie_2(void)
{
/*fallback for online examples*/
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Lottie cannot be previewed online");
lv_obj_center(label);
}
#endif /*LV_USE_LOTTIE*/
#endif /*LV_BUILD_EXAMPLES*/
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3
View File
@@ -97,6 +97,9 @@ void lv_example_line_1(void);
void lv_example_list_1(void);
void lv_example_list_2(void);
void lv_example_lottie_1(void);
void lv_example_lottie_2(void);
void lv_example_menu_1(void);
void lv_example_menu_2(void);
void lv_example_menu_3(void);