diff --git a/examples/LottieExtension.cpp b/examples/LottieExtension.cpp index 1f039cdb..59eae5b7 100644 --- a/examples/LottieExtension.cpp +++ b/examples/LottieExtension.cpp @@ -32,6 +32,7 @@ struct UserExample : tvgexam::Example unique_ptr slot0; unique_ptr slot1; unique_ptr slot2; + unique_ptr slot3; unique_ptr marker; uint32_t w, h; uint32_t size; @@ -78,6 +79,12 @@ struct UserExample : tvgexam::Example slot2->frame(slot2->totalFrame() * progress); } + //image slot + { + auto progress = tvgexam::progress(elapsed, slot3->duration()); + slot3->frame(slot3->totalFrame() * progress); + } + //marker { auto progress = tvgexam::progress(elapsed, marker->duration()); @@ -142,6 +149,20 @@ struct UserExample : tvgexam::Example canvas->push(picture); } + //slot (image) + { + slot3 = std::unique_ptr(tvg::LottieAnimation::gen()); + auto picture = slot3->picture(); + if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slotsample3.json"))) return false; + + const char* slotJson = R"({"path_img":{"id":"image_0","w":200,"h":300,"u":"images/","p":"logo.png","e":0}})"; + if (!tvgexam::verify(slot3->override(slotJson))) return false; + + sizing(picture, 3); + + canvas->push(picture); + } + //marker { marker = std::unique_ptr(tvg::LottieAnimation::gen()); @@ -149,7 +170,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, 3); + sizing(picture, 4); canvas->push(picture); } diff --git a/examples/resources/lottie/extensions/images/img_0.png b/examples/resources/lottie/extensions/images/img_0.png new file mode 100644 index 00000000..35ee257c Binary files /dev/null and b/examples/resources/lottie/extensions/images/img_0.png differ diff --git a/examples/resources/lottie/extensions/images/logo.png b/examples/resources/lottie/extensions/images/logo.png new file mode 100644 index 00000000..b08abf8b Binary files /dev/null and b/examples/resources/lottie/extensions/images/logo.png differ diff --git a/examples/resources/lottie/extensions/slotsample3.json b/examples/resources/lottie/extensions/slotsample3.json new file mode 100644 index 00000000..c6773334 --- /dev/null +++ b/examples/resources/lottie/extensions/slotsample3.json @@ -0,0 +1 @@ +{"v":"5.4.3","fr":60,"ip":0,"op":60,"w":800,"h":800,"nm":"test","ddd":0,"assets":[{"id":"image_0","w":200,"h":300,"u":"images/","p":"img_0.png","e":0,"sid":"path_img"}],"layers":[{"ddd":0,"ind":1,"ty":2,"nm":"img_0.png","cl":"png","refId":"image_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[56]},{"t":50}],"ix":10},"p":{"a":0,"k":[400,400,0],"ix":2},"a":{"a":0,"k":[100,150,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"t":0,"s":[99,99,100],"e":[152,152,100]},{"t":50}],"ix":6}},"ao":0,"ip":0,"op":60,"st":0,"bm":0}],"markers":[]} \ No newline at end of file