mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
lottie: fix text range opacity
This commit is contained in:
parent
552d4bcee1
commit
ce3bee7a3f
1 changed files with 9 additions and 3 deletions
|
@ -1091,6 +1091,9 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
|||
Point translation = {0.0f, 0.0f};
|
||||
auto color = doc.color;
|
||||
auto strokeColor = doc.stroke.color;
|
||||
uint8_t opacity = 255;
|
||||
uint8_t fillOpacity = 255;
|
||||
uint8_t strokeOpacity = 255;
|
||||
|
||||
for (auto s = text->ranges.begin(); s < text->ranges.end(); ++s) {
|
||||
auto basedIdx = idx;
|
||||
|
@ -1116,7 +1119,8 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
|||
scaling.y *= temp.y;
|
||||
rotation += f * (*s)->style.rotation(frameNo);
|
||||
|
||||
shape->opacity((*s)->style.opacity(frameNo));
|
||||
opacity = (uint8_t)(opacity - f * (opacity - (*s)->style.opacity(frameNo)));
|
||||
shape->opacity(opacity);
|
||||
|
||||
auto rangeColor = (*s)->style.fillColor(frameNo); //TODO: use flag to check whether it was really set
|
||||
if (tvg::equal(f, 1.0f)) color = rangeColor;
|
||||
|
@ -1125,7 +1129,8 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
|||
color.rgb[1] = lerp<uint8_t>(color.rgb[1], rangeColor.rgb[1], f);
|
||||
color.rgb[2] = lerp<uint8_t>(color.rgb[2], rangeColor.rgb[2], f);
|
||||
}
|
||||
shape->fill(color.rgb[0], color.rgb[1], color.rgb[2], (*s)->style.fillOpacity(frameNo));
|
||||
fillOpacity = (uint8_t)(fillOpacity - f * (fillOpacity - (*s)->style.fillOpacity(frameNo)));
|
||||
shape->fill(color.rgb[0], color.rgb[1], color.rgb[2], fillOpacity);
|
||||
|
||||
if (doc.stroke.render) {
|
||||
shape->stroke(f * (*s)->style.strokeWidth(frameNo) / scale);
|
||||
|
@ -1136,7 +1141,8 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
|||
strokeColor.rgb[1] = lerp<uint8_t>(strokeColor.rgb[1], rangeColor.rgb[1], f);
|
||||
strokeColor.rgb[2] = lerp<uint8_t>(strokeColor.rgb[2], rangeColor.rgb[2], f);
|
||||
}
|
||||
shape->stroke(strokeColor.rgb[0], strokeColor.rgb[1], strokeColor.rgb[2], (*s)->style.strokeOpacity(frameNo));
|
||||
strokeOpacity = (uint8_t)(strokeOpacity - f * (strokeOpacity - (*s)->style.strokeOpacity(frameNo)));
|
||||
shape->stroke(strokeColor.rgb[0], strokeColor.rgb[1], strokeColor.rgb[2], strokeOpacity);
|
||||
}
|
||||
|
||||
cursor.x += f * (*s)->style.letterSpacing(frameNo);
|
||||
|
|
Loading…
Add table
Reference in a new issue