From c9a2e58ae376096c4706fc8b52be0d7b27fe7949 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 30 Jun 2026 13:13:26 +0900 Subject: [PATCH] LottieTweening: apply the dynamic tweening see: https://github.com/thorvg/thorvg/issues/4295 --- src/LottieTweening.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/LottieTweening.cpp b/src/LottieTweening.cpp index 5ca7f39..c1dd816 100644 --- a/src/LottieTweening.cpp +++ b/src/LottieTweening.cpp @@ -41,8 +41,6 @@ struct UserExample : tvgexam::Example int stateIdx = 0; //current state index struct { - float from; //tweening from frame number - float to; //tweening to frame number float beginTime; //tweening begin time bool active = false; //whether on-tweening or not } tween; @@ -74,7 +72,7 @@ struct UserExample : tvgexam::Example void tweening(int stateIdx) { //don't allow the overlapped tweening - if (tween.active || stateIdx == this->stateIdx) return; + if (stateIdx == this->stateIdx) return; //reset the current state lottie->segment(nullptr); @@ -82,11 +80,8 @@ struct UserExample : tvgexam::Example //tweening trigger time tween.beginTime = timestamp(); - //the current animation frame as the tweening "from" frame - tween.from = lottie->curFrame(); - //the next state begin frame as the tweening "to" frame - tween.to = states[stateIdx].begin; + lottie->tweenTo(states[stateIdx].begin); tween.active = true; @@ -151,7 +146,7 @@ struct UserExample : tvgexam::Example //perform the tweening effect if (progress < 1.0f) { - if (lottie->tween(tween.from, tween.to, progress) == tvg::Result(0)) { + if (lottie->tween(progress) == tvg::Result(0)) { canvas->update(); return true; }