mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 06:04:03 +00:00
example
This commit is contained in:
parent
df58466ce7
commit
acdec3d294
2 changed files with 85 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <thorvg_lottie.h>
|
||||
#include "Example.h"
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -28,12 +29,12 @@
|
|||
|
||||
struct UserExample : tvgexam::Example
|
||||
{
|
||||
unique_ptr<tvg::Animation> animation;
|
||||
unique_ptr<tvg::LottieAnimation> animation;
|
||||
|
||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||
{
|
||||
//Animation Controller
|
||||
animation = unique_ptr<tvg::Animation>(tvg::Animation::gen());
|
||||
animation = unique_ptr<tvg::LottieAnimation>(tvg::LottieAnimation::gen());
|
||||
auto picture = animation->picture();
|
||||
|
||||
//Background
|
||||
|
@ -45,6 +46,9 @@ struct UserExample : tvgexam::Example
|
|||
|
||||
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/sample.json"))) return false;
|
||||
|
||||
const char* slotJson = R"({"rect_position":{"p":{"x": "var $bm_rt = [];\n$bm_rt[0] = value[0] + Math.cos(2 * Math.PI * time) * 100;\n$bm_rt[1] = value[1];"}}})";
|
||||
if (!tvgexam::verify(animation->override(slotJson))) return false;
|
||||
|
||||
//image scaling preserving its aspect ratio
|
||||
float scale;
|
||||
float shiftX = 0.0f, shiftY = 0.0f;
|
||||
|
@ -90,5 +94,6 @@ struct UserExample : tvgexam::Example
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return tvgexam::main(new UserExample, argc, argv, false, 1024, 1024);
|
||||
// Ensure thread is 1 for expression support
|
||||
return tvgexam::main(new UserExample, argc, argv, false, 1024, 1024, 1);
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue