mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
lottie: enhance parsing of position's SeparateCoords
The "s" key does not have to appear at the beginning of the position block. Previously, such cases would result in a parsing error — now they are handled correctly.
This commit is contained in:
parent
a21ecdc1ae
commit
a6898ccf42
2 changed files with 14 additions and 5 deletions
|
@ -553,6 +553,12 @@ struct LottieTransform : LottieObject
|
|||
LottieFloat y = 0.0f;
|
||||
};
|
||||
|
||||
SeparateCoord* separateCoord()
|
||||
{
|
||||
if (!coords) coords = new SeparateCoord;
|
||||
return coords;
|
||||
}
|
||||
|
||||
struct RotationEx
|
||||
{
|
||||
LottieFloat x = 0.0f;
|
||||
|
|
|
@ -603,11 +603,14 @@ LottieTransform* LottieParser::parseTransform(bool ddd)
|
|||
enterObject();
|
||||
while (auto key = nextObjectKey()) {
|
||||
if (KEY_AS("k")) parsePropertyInternal(transform->position);
|
||||
else if (KEY_AS("s") && getBool()) transform->coords = new LottieTransform::SeparateCoord;
|
||||
//check separateCoord to figure out whether "x(expression)" / "x(coord)"
|
||||
else if (transform->coords && KEY_AS("x")) parseProperty<LottieProperty::Type::Float>(transform->coords->x);
|
||||
else if (transform->coords && KEY_AS("y")) parseProperty<LottieProperty::Type::Float>(transform->coords->y);
|
||||
else if (KEY_AS("x")) transform->position.exp = _expression(getStringCopy(), comp, context.layer, context.parent, &transform->position);
|
||||
else if (KEY_AS("x"))
|
||||
{
|
||||
//check separateCoord to figure out whether "x(expression)" / "x(coord)"
|
||||
if (peekType() == kStringType) transform->position.exp = _expression(getStringCopy(), comp, context.layer, context.parent, &transform->position);
|
||||
else parseProperty(transform->separateCoord()->x);
|
||||
}
|
||||
else if (KEY_AS("y")) parseProperty(transform->separateCoord()->y);
|
||||
|
||||
else if (KEY_AS("sid")) registerSlot<LottieProperty::Type::Position>(transform, getString());
|
||||
else skip(key);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue