example/lottie_extension: added overriden default slot sample

This commit is contained in:
Hermet Park 2024-11-18 16:27:29 +09:00 committed by Hermet Park
parent 0b0488df82
commit 8107582c8b
2 changed files with 1036 additions and 1 deletions

View file

@ -33,6 +33,7 @@ struct UserExample : tvgexam::Example
unique_ptr<tvg::LottieAnimation> slot1;
unique_ptr<tvg::LottieAnimation> slot2;
unique_ptr<tvg::LottieAnimation> slot3;
unique_ptr<tvg::LottieAnimation> slot4;
unique_ptr<tvg::LottieAnimation> marker;
uint32_t w, h;
uint32_t size;
@ -85,6 +86,12 @@ struct UserExample : tvgexam::Example
slot3->frame(slot3->totalFrame() * progress);
}
//overriden default slot
{
auto progress = tvgexam::progress(elapsed, slot4->duration());
slot4->frame(slot4->totalFrame() * progress);
}
//marker
{
auto progress = tvgexam::progress(elapsed, marker->duration());
@ -163,6 +170,20 @@ struct UserExample : tvgexam::Example
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 = 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(marker->segment("sectionC"))) return false;
sizing(picture, 4);
sizing(picture, 5);
canvas->push(picture);
}

File diff suppressed because it is too large Load diff