From ac2b5c86e6d50cdf616abcd3c788f029d29b3ff0 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Wed, 28 Aug 2024 16:47:57 +0200 Subject: [PATCH] lottie: handle trim path edge cases According to the definition of trim path elements, the begin and end values are specified as percentages in the range of 0-100% (this is also confirmed by AE, where it's not possible to exceed this range). Added clamping to align with spec. --- src/loaders/lottie/tvgLottieModel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/loaders/lottie/tvgLottieModel.cpp b/src/loaders/lottie/tvgLottieModel.cpp index 41339cef..2707a445 100644 --- a/src/loaders/lottie/tvgLottieModel.cpp +++ b/src/loaders/lottie/tvgLottieModel.cpp @@ -141,7 +141,9 @@ void LottieImage::prepare() void LottieTrimpath::segment(float frameNo, float& start, float& end, LottieExpressions* exps) { start = this->start(frameNo, exps) * 0.01f; + tvg::clamp(start, 0.0f, 1.0f); end = this->end(frameNo, exps) * 0.01f; + tvg::clamp(end, 0.0f, 1.0f); auto o = fmodf(this->offset(frameNo, exps), 360.0f) / 360.0f; //0 ~ 1