mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
examples/slot: added example for image slot overriding
This commit is contained in:
parent
efe7440fa0
commit
4ec7ce65bc
4 changed files with 23 additions and 1 deletions
|
@ -32,6 +32,7 @@ struct UserExample : tvgexam::Example
|
|||
unique_ptr<tvg::LottieAnimation> slot0;
|
||||
unique_ptr<tvg::LottieAnimation> slot1;
|
||||
unique_ptr<tvg::LottieAnimation> slot2;
|
||||
unique_ptr<tvg::LottieAnimation> slot3;
|
||||
unique_ptr<tvg::LottieAnimation> 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>(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>(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);
|
||||
}
|
||||
|
|
BIN
examples/resources/lottie/extensions/images/img_0.png
Normal file
BIN
examples/resources/lottie/extensions/images/img_0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
BIN
examples/resources/lottie/extensions/images/logo.png
Normal file
BIN
examples/resources/lottie/extensions/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
1
examples/resources/lottie/extensions/slotsample3.json
Normal file
1
examples/resources/lottie/extensions/slotsample3.json
Normal file
|
@ -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":[]}
|
Loading…
Add table
Reference in a new issue