mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
lottie: multiply opacity to the fill alpha value,
opacity of a shape may bring a composition when it has both stroke and fill
This commit is contained in:
parent
7e8eee6e3b
commit
f5af7b13a5
2 changed files with 12 additions and 1 deletions
|
@ -304,7 +304,6 @@ void LottieBuilder::updateGradientFill(LottieGroup* parent, LottieObject** child
|
|||
//TODO: reuse the fill instance?
|
||||
ctx->propagator->fill(unique_ptr<Fill>(fill->fill(frameNo, exps)));
|
||||
ctx->propagator->fill(fill->rule);
|
||||
ctx->propagator->opacity(MULTIPLY(fill->opacity(frameNo), PP(ctx->propagator)->opacity));
|
||||
|
||||
if (ctx->propagator->strokeWidth() > 0) ctx->propagator->order(true);
|
||||
}
|
||||
|
|
|
@ -272,6 +272,9 @@ uint32_t LottieGradient::populate(ColorStop& color, size_t count)
|
|||
|
||||
Fill* LottieGradient::fill(float frameNo, LottieExpressions* exps)
|
||||
{
|
||||
auto opacity = this->opacity(frameNo);
|
||||
if (opacity == 0) return nullptr;
|
||||
|
||||
Fill* fill = nullptr;
|
||||
auto s = start(frameNo, exps);
|
||||
auto e = end(frameNo, exps);
|
||||
|
@ -307,6 +310,15 @@ Fill* LottieGradient::fill(float frameNo, LottieExpressions* exps)
|
|||
|
||||
colorStops(frameNo, fill, exps);
|
||||
|
||||
//multiply the current opacity with the fill
|
||||
if (opacity < 255) {
|
||||
const Fill::ColorStop* colorStops;
|
||||
auto cnt = fill->colorStops(&colorStops);
|
||||
for (uint32_t i = 0; i < cnt; ++i) {
|
||||
const_cast<Fill::ColorStop*>(&colorStops[i])->a = MULTIPLY(colorStops[i].a, opacity);
|
||||
}
|
||||
}
|
||||
|
||||
return fill;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue