mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
example/lottie_extension: added overriden default slot sample
This commit is contained in:
parent
0b0488df82
commit
8107582c8b
2 changed files with 1036 additions and 1 deletions
|
@ -33,6 +33,7 @@ struct UserExample : tvgexam::Example
|
||||||
unique_ptr<tvg::LottieAnimation> slot1;
|
unique_ptr<tvg::LottieAnimation> slot1;
|
||||||
unique_ptr<tvg::LottieAnimation> slot2;
|
unique_ptr<tvg::LottieAnimation> slot2;
|
||||||
unique_ptr<tvg::LottieAnimation> slot3;
|
unique_ptr<tvg::LottieAnimation> slot3;
|
||||||
|
unique_ptr<tvg::LottieAnimation> slot4;
|
||||||
unique_ptr<tvg::LottieAnimation> marker;
|
unique_ptr<tvg::LottieAnimation> marker;
|
||||||
uint32_t w, h;
|
uint32_t w, h;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
@ -85,6 +86,12 @@ struct UserExample : tvgexam::Example
|
||||||
slot3->frame(slot3->totalFrame() * progress);
|
slot3->frame(slot3->totalFrame() * progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//overriden default slot
|
||||||
|
{
|
||||||
|
auto progress = tvgexam::progress(elapsed, slot4->duration());
|
||||||
|
slot4->frame(slot4->totalFrame() * progress);
|
||||||
|
}
|
||||||
|
|
||||||
//marker
|
//marker
|
||||||
{
|
{
|
||||||
auto progress = tvgexam::progress(elapsed, marker->duration());
|
auto progress = tvgexam::progress(elapsed, marker->duration());
|
||||||
|
@ -163,6 +170,20 @@ struct UserExample : tvgexam::Example
|
||||||
canvas->push(picture);
|
canvas->push(picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//slot (overriden default slot)
|
||||||
|
{
|
||||||
|
slot4 = std::unique_ptr<tvg::LottieAnimation>(tvg::LottieAnimation::gen());
|
||||||
|
auto picture = slot4->picture();
|
||||||
|
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slotsample4.json"))) return false;
|
||||||
|
|
||||||
|
const char* slotJson = R"({"bg_color":{"p":{"a":0,"k":[1,0.8196,0.2275]}},"check_color":{"p":{"a":0,"k":[0.0078,0.0078,0.0078]}}})";
|
||||||
|
if (!tvgexam::verify(slot4->override(slotJson))) return false;
|
||||||
|
|
||||||
|
sizing(picture, 4);
|
||||||
|
|
||||||
|
canvas->push(picture);
|
||||||
|
}
|
||||||
|
|
||||||
//marker
|
//marker
|
||||||
{
|
{
|
||||||
marker = std::unique_ptr<tvg::LottieAnimation>(tvg::LottieAnimation::gen());
|
marker = std::unique_ptr<tvg::LottieAnimation>(tvg::LottieAnimation::gen());
|
||||||
|
@ -170,7 +191,7 @@ struct UserExample : tvgexam::Example
|
||||||
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/marker_sample.json"))) return false;
|
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/marker_sample.json"))) return false;
|
||||||
if (!tvgexam::verify(marker->segment("sectionC"))) return false;
|
if (!tvgexam::verify(marker->segment("sectionC"))) return false;
|
||||||
|
|
||||||
sizing(picture, 4);
|
sizing(picture, 5);
|
||||||
|
|
||||||
canvas->push(picture);
|
canvas->push(picture);
|
||||||
}
|
}
|
||||||
|
|
1014
examples/resources/lottie/extensions/slotsample4.json
Normal file
1014
examples/resources/lottie/extensions/slotsample4.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue