App:Library:LVGL:docs:3rd party libraries:Lottie player
https://docs.lvgl.io/8.2/libs/rlottie.html
Lottie player
英文 | 自動翻訳 |
---|---|
Allows to use Lottie animations in LVGL. Taken from this base repository LVGL provides the interface to Samsung/rlottie library's C API. That is the actual Lottie player is not part of LVGL, it needs to be built separately. |
Build Rlottie
英文 | 自動翻訳 |
---|---|
To build Samsung's Rlottie C++14-compatible compiler and optionally CMake 3.14 or higher is required. To build on desktop you can follow the instructions from Rlottie's README. In the most basic case it looks like this: mkdir rlottie_workdir cd rlottie_workdir git clone https://github.com/Samsung/rlottie.git mkdir build cd build cmake ../rlottie make -j sudo make install And finally add the On embedded systems you need to take care of integrating Rlottie to the given build system. |
Usage
英文 | 自動翻訳 |
---|---|
You can use animation from files or raw data (text). In either case first you need to enable The |
Use Rlottie from file
英文 | 自動翻訳 |
---|---|
To create a Lottie animation from file use: lv_obj_t * lottie = lv_rlottie_create_from_file(parent, width, height, "path/to/lottie.json"); Note that, Rlottie uses the standard STDIO C file API, so you can use the path "normally" and no LVGL specific driver letter is required. |
Use Rlottie from raw string data
英文 | 自動翻訳 |
---|---|
./filetohex.py path/to/lottie.json > out.txt To create an animation from raw data: extern const uint8_t lottie_data[]; lv_obj_t* lottie = lv_rlottie_create_from_raw(parent, width, height, (const char *)lottie_data); |
Getting animations
英文 | 自動翻訳 |
---|---|
Lottie is standard and popular format so you can find many animation files on the web. For example: https://lottiefiles.com/ You can also create your own animations with Adobe After Effects or similar software. |
Controlling animations
英文 | 自動翻訳 |
---|---|
LVGL provides two functions to control the animation mode: lv_obj_t * lottie = lv_rlottie_create_from_file(scr, 128, 128, "test.json"); lv_obj_center(lottie); // Pause to a specific frame lv_rlottie_set_current_frame(lottie, 50); lv_rlottie_set_play_mode(lottie, LV_RLOTTIE_CTRL_PAUSE); // The specified frame will be displayed and then the animation will pause // Play backward and loop lv_rlottie_set_play_mode(lottie, LV_RLOTTIE_CTRL_PLAY | LV_RLOTTIE_CTRL_BACKWARD | LV_RLOTTIE_CTRL_LOOP); // Play forward once (no looping) lv_rlottie_set_play_mode(lottie, LV_RLOTTIE_CTRL_PLAY | LV_RLOTTIE_CTRL_FORWARD); The default animation mode is play forward with loop. If you don't enable looping, a To get the number of frames in an animation or the current frame index, you can cast the |
Example
英文 | 自動翻訳 |
---|---|
Load a Lottie animation from raw data |
|
Load a Lottie animation from a file |
API
英文 | 自動翻訳 |
---|---|
Enums enum lv_rlottie_ctrl_t
Functions lv_obj_t *lv_rlottie_create_from_file(lv_obj_t *parent, lv_coord_t width, lv_coord_t height, const char *path) lv_obj_t *lv_rlottie_create_from_raw(lv_obj_t *parent, lv_coord_t width, lv_coord_t height, const char *rlottie_desc) void lv_rlottie_set_play_mode(lv_obj_t *rlottie, const lv_rlottie_ctrl_t ctrl) void lv_rlottie_set_current_frame(lv_obj_t *rlottie, const size_t goto_frame) Variables const lv_obj_class_t lv_rlottie_class struct lv_rlottie_t
|