diff --git a/inc/thorvg.h b/inc/thorvg.h index 5b152810..d56c8ada 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1805,6 +1805,7 @@ public: * * @note For efficiency, ThorVG ignores updates to the new frame value if the difference from the current frame value * is less than 0.001. In such cases, it returns @c Result::InsufficientCondition. + * Values less than 0.001 may be disregarded and may not be accurately retained by the Animation. * * @see totalFrame() * diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 52dd5518..da740f06 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -2254,6 +2254,7 @@ TVG_API Tvg_Animation* tvg_animation_new(); * * \note For efficiency, ThorVG ignores updates to the new frame value if the difference from the current frame value * is less than 0.001. In such cases, it returns @c Result::InsufficientCondition. +* Values less than 0.001 may be disregarded and may not be accurately retained by the Animation. * \see tvg_animation_get_total_frame() * * \since 0.13 diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index 01057f42..5bd8fca1 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -313,17 +313,19 @@ bool LottieLoader::override(const char* slot) bool LottieLoader::frame(float no) { + auto frameNo = no + startFrame(); + + //This ensures that the target frame number is reached. + frameNo *= 10000.0f; + frameNo = roundf(frameNo); + frameNo *= 0.0001f; + //Skip update if frame diff is too small. - if (fabsf(this->frameNo - no) < 0.0009f) return false; + if (fabsf(this->frameNo - frameNo) <= 0.0009f) return false; this->done(); - //This ensures that the perfect last frame is reached. - no *= 1000.0f; - no = roundf(no); - no *= 0.001f; - - this->frameNo = no + startFrame(); + this->frameNo = frameNo; TaskScheduler::request(this);