mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
example: ++lottie extension
This commit is contained in:
parent
e811a513f2
commit
97058badbf
2 changed files with 20 additions and 1 deletions
|
@ -34,6 +34,7 @@ struct UserExample : tvgexam::Example
|
|||
unique_ptr<tvg::LottieAnimation> slot2;
|
||||
unique_ptr<tvg::LottieAnimation> slot3;
|
||||
unique_ptr<tvg::LottieAnimation> slot4;
|
||||
unique_ptr<tvg::LottieAnimation> slot5;
|
||||
unique_ptr<tvg::LottieAnimation> marker;
|
||||
uint32_t w, h;
|
||||
uint32_t size;
|
||||
|
@ -92,6 +93,12 @@ struct UserExample : tvgexam::Example
|
|||
slot4->frame(slot4->totalFrame() * progress);
|
||||
}
|
||||
|
||||
//duplicate slot
|
||||
{
|
||||
auto progress = tvgexam::progress(elapsed, slot5->duration());
|
||||
slot5->frame(slot5->totalFrame() * progress);
|
||||
}
|
||||
|
||||
//marker
|
||||
{
|
||||
auto progress = tvgexam::progress(elapsed, marker->duration());
|
||||
|
@ -184,6 +191,17 @@ struct UserExample : tvgexam::Example
|
|||
canvas->push(picture);
|
||||
}
|
||||
|
||||
//slot (duplicate slots with default)
|
||||
{
|
||||
slot5 = std::unique_ptr<tvg::LottieAnimation>(tvg::LottieAnimation::gen());
|
||||
auto picture = slot5->picture();
|
||||
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slotsample5.json"))) return false;
|
||||
|
||||
sizing(picture, 5);
|
||||
|
||||
canvas->push(picture);
|
||||
}
|
||||
|
||||
//marker
|
||||
{
|
||||
marker = std::unique_ptr<tvg::LottieAnimation>(tvg::LottieAnimation::gen());
|
||||
|
@ -191,7 +209,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, 5);
|
||||
sizing(picture, 6);
|
||||
|
||||
canvas->push(picture);
|
||||
}
|
||||
|
|
1
examples/resources/lottie/extensions/slotsample5.json
Normal file
1
examples/resources/lottie/extensions/slotsample5.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"nm":"Main Scene","ddd":0,"h":500,"w":500,"meta":{"g":"@lottiefiles/creator 1.37.0"},"layers":[{"ty":4,"nm":"Rectangle 2","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[304.5,352.2827]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"rc","bm":0,"hd":false,"nm":"Rectangle Path 2","d":1,"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"s":{"a":0,"k":[133,98.56532879503823]}},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[1,0.5569,0.9255],"t":0},{"s":[0.3176,0.0157,0.2667],"t":23}],"sid":"sdf"},"r":1,"o":{"a":0,"k":100}}],"ind":1},{"ty":4,"nm":"Rectangle 1","sr":1,"st":0,"op":150,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[133,210.8551]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"rc","bm":0,"hd":false,"nm":"Rectangle Path 1","d":1,"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"s":{"a":0,"k":[58.00000000000001,65.71021919669215]}},{"ty":"fl","bm":0,"hd":false,"nm":"Fill","c":{"a":0,"k":[1,0.5569,0.9255],"sid":"sdf"},"r":1,"o":{"a":0,"k":100}}],"ind":2}],"v":"5.7.0","fr":30,"op":150,"ip":0,"assets":[],"slots":{"sdf":{"p":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[1,0.5569,0.9255],"t":0},{"s":[0.3176,0.0157,0.2667],"t":23}]}}}}
|
Loading…
Add table
Reference in a new issue