loader/lottie: Add radial gradient support

This allows for the creation of basic radial gradients,
without support for focal points.
This commit is contained in:
Hermet Park 2023-08-09 16:01:29 +09:00 committed by Hermet Park
parent d7c70c5371
commit 8f4f3d6f1b
2 changed files with 9 additions and 1 deletions

File diff suppressed because one or more lines are too long

View file

@ -49,7 +49,14 @@ Fill* LottieGradient::fill(int32_t frameNo)
//Radial Gradient
if (id == 2) {
fill = RadialGradient::gen().release();
TVGLOG("LOTTIE", "TODO: Missing Radial Gradient!");
auto sx = start(frameNo).x;
auto sy = start(frameNo).y;
auto w = fabsf(end(frameNo).x - sx);
auto h = fabsf(end(frameNo).y - sy);
auto radius = (w > h) ? (w + 0.375f * h) : (h + 0.375f * w);
static_cast<RadialGradient*>(fill)->radial(sx, sy, radius);
//TODO: focal support?
}
if (!fill) return nullptr;