From 1c48cd3cdcbfa5a1601b98a1d51ed83a2a73cbb9 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Mon, 30 Sep 2024 13:59:52 +0200 Subject: [PATCH] lottie: fix gradient populating When populating the gradient, the color/alpha should be assigned the first possible value from the provided ones, rather than the default value of 255. --- src/loaders/lottie/tvgLottieModel.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/loaders/lottie/tvgLottieModel.cpp b/src/loaders/lottie/tvgLottieModel.cpp index 2b2793ea..e64565dd 100644 --- a/src/loaders/lottie/tvgLottieModel.cpp +++ b/src/loaders/lottie/tvgLottieModel.cpp @@ -216,7 +216,7 @@ uint32_t LottieGradient::populate(ColorStop& color) if (output.count > 0) { auto p = ((*color.input)[cidx] - output.last().offset) / ((*color.input)[aidx] - output.last().offset); cs.a = lerp(output.last().a, (uint8_t)nearbyint((*color.input)[aidx + 1] * 255.0f), p); - } else cs.a = 255; + } else cs.a = (uint8_t)nearbyint((*color.input)[aidx + 1] * 255.0f); cidx += 4; } else { cs.offset = (*color.input)[aidx]; @@ -227,7 +227,11 @@ uint32_t LottieGradient::populate(ColorStop& color) cs.r = lerp(output.last().r, (uint8_t)nearbyint((*color.input)[cidx + 1] * 255.0f), p); cs.g = lerp(output.last().g, (uint8_t)nearbyint((*color.input)[cidx + 2] * 255.0f), p); cs.b = lerp(output.last().b, (uint8_t)nearbyint((*color.input)[cidx + 3] * 255.0f), p); - } else cs.r = cs.g = cs.b = 255; + } else { + cs.r = (uint8_t)nearbyint((*color.input)[cidx + 1] * 255.0f); + cs.g = (uint8_t)nearbyint((*color.input)[cidx + 2] * 255.0f); + cs.b = (uint8_t)nearbyint((*color.input)[cidx + 3] * 255.0f); + } aidx += 2; } output.push(cs);