mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 04:24:28 +00:00
lottie: fixed a repeater opacity logic
preserve the target opacity by multiplying, do not overwrite it.
This commit is contained in:
parent
6c1b388d77
commit
a2665cbab7
2 changed files with 3 additions and 8 deletions
|
@ -352,13 +352,11 @@ static void _repeat(LottieGroup* parent, Shape* path, RenderContext* ctx)
|
||||||
|
|
||||||
for (int i = 0; i < repeater->cnt; ++i) {
|
for (int i = 0; i < repeater->cnt; ++i) {
|
||||||
auto multiplier = repeater->offset + static_cast<float>(i);
|
auto multiplier = repeater->offset + static_cast<float>(i);
|
||||||
|
|
||||||
ARRAY_FOREACH(p, propagators) {
|
ARRAY_FOREACH(p, propagators) {
|
||||||
auto shape = static_cast<Shape*>((*p)->duplicate());
|
auto shape = static_cast<Shape*>((*p)->duplicate());
|
||||||
SHAPE(shape)->rs.path = SHAPE(path)->rs.path;
|
SHAPE(shape)->rs.path = SHAPE(path)->rs.path;
|
||||||
|
auto opacity = tvg::lerp<uint8_t>(repeater->startOpacity, repeater->endOpacity, static_cast<float>(i + 1) / repeater->cnt);
|
||||||
auto opacity = repeater->interpOpacity ? tvg::lerp<uint8_t>(repeater->startOpacity, repeater->endOpacity, static_cast<float>(i + 1) / repeater->cnt) : repeater->startOpacity;
|
shape->opacity(MULTIPLY((*p)->opacity(), opacity));
|
||||||
shape->opacity(opacity);
|
|
||||||
|
|
||||||
Matrix m;
|
Matrix m;
|
||||||
tvg::identity(&m);
|
tvg::identity(&m);
|
||||||
|
@ -366,11 +364,10 @@ static void _repeat(LottieGroup* parent, Shape* path, RenderContext* ctx)
|
||||||
scale(&m, {powf(repeater->scale.x * 0.01f, multiplier), powf(repeater->scale.y * 0.01f, multiplier)});
|
scale(&m, {powf(repeater->scale.x * 0.01f, multiplier), powf(repeater->scale.y * 0.01f, multiplier)});
|
||||||
rotate(&m, repeater->rotation * multiplier);
|
rotate(&m, repeater->rotation * multiplier);
|
||||||
translateR(&m, -repeater->anchor);
|
translateR(&m, -repeater->anchor);
|
||||||
m = repeater->transform * m;
|
|
||||||
|
|
||||||
Matrix inv;
|
Matrix inv;
|
||||||
inverse(&repeater->transform, &inv);
|
inverse(&repeater->transform, &inv);
|
||||||
shape->transform(m * (inv * shape->transform()));
|
shape->transform((repeater->transform * m) * (inv * shape->transform()));
|
||||||
shapes.push(shape);
|
shapes.push(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,7 +736,6 @@ void LottieBuilder::updateRepeater(TVG_UNUSED LottieGroup* parent, LottieObject*
|
||||||
r.startOpacity = repeater->startOpacity(frameNo, tween, exps);
|
r.startOpacity = repeater->startOpacity(frameNo, tween, exps);
|
||||||
r.endOpacity = repeater->endOpacity(frameNo, tween, exps);
|
r.endOpacity = repeater->endOpacity(frameNo, tween, exps);
|
||||||
r.inorder = repeater->inorder;
|
r.inorder = repeater->inorder;
|
||||||
r.interpOpacity = (r.startOpacity == r.endOpacity) ? false : true;
|
|
||||||
ctx->repeaters.push(r);
|
ctx->repeaters.push(r);
|
||||||
|
|
||||||
ctx->merging = nullptr;
|
ctx->merging = nullptr;
|
||||||
|
|
|
@ -42,7 +42,6 @@ struct RenderRepeater
|
||||||
float rotation;
|
float rotation;
|
||||||
uint8_t startOpacity;
|
uint8_t startOpacity;
|
||||||
uint8_t endOpacity;
|
uint8_t endOpacity;
|
||||||
bool interpOpacity;
|
|
||||||
bool inorder;
|
bool inorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue