diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index 1f0debef..811c61ab 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -532,6 +532,18 @@ bool LottieParser::parseCommon(LottieObject* obj, const char* key) } +bool LottieParser::parseDirection(LottieShape* shape, const char* key) +{ + if (KEY_AS("d")) { + if (getInt() == 3) { + shape->clockwise = false; //default is true + } + return true; + } + return false; +} + + LottieRect* LottieParser::parseRect() { auto rect = new LottieRect; @@ -543,7 +555,7 @@ LottieRect* LottieParser::parseRect() else if (KEY_AS("s")) parseProperty(rect->size); else if (KEY_AS("p")) parseProperty(rect->position); else if (KEY_AS("r")) parseProperty(rect->radius); - else if (KEY_AS("d")) rect->clockwise = getDirection(); + else if (parseDirection(rect, key)) continue; else skip(key); } rect->prepare(); @@ -561,7 +573,7 @@ LottieEllipse* LottieParser::parseEllipse() if (parseCommon(ellipse, key)) continue; else if (KEY_AS("p")) parseProperty(ellipse->position); else if (KEY_AS("s")) parseProperty(ellipse->size); - else if (KEY_AS("d")) ellipse->clockwise = getDirection(); + else if (parseDirection(ellipse, key)) continue; else skip(key); } ellipse->prepare(); @@ -698,7 +710,7 @@ LottiePath* LottieParser::parsePath() while (auto key = nextObjectKey()) { if (parseCommon(path, key)) continue; else if (KEY_AS("ks")) getPathSet(path->pathset); - else if (KEY_AS("d")) path->clockwise = getDirection(); + else if (parseDirection(path, key)) continue; else skip(key); } path->prepare(); @@ -722,7 +734,7 @@ LottiePolyStar* LottieParser::parsePolyStar() else if (KEY_AS("os")) parseProperty(star->outerRoundness); else if (KEY_AS("r")) parseProperty(star->rotation); else if (KEY_AS("sy")) star->type = (LottiePolyStar::Type) getInt(); - else if (KEY_AS("d")) star->clockwise = getDirection(); + else if (parseDirection(star, key)) continue; else skip(key); } star->prepare(); @@ -1086,13 +1098,6 @@ void LottieParser::parseTimeRemap(LottieLayer* layer) } -uint8_t LottieParser::getDirection() -{ - if (getInt() == 3) return false; - return true; -} - - void LottieParser::parseShapes(Array& parent) { enterArray(); diff --git a/src/loaders/lottie/tvgLottieParser.h b/src/loaders/lottie/tvgLottieParser.h index e731f600..f59d9a3a 100644 --- a/src/loaders/lottie/tvgLottieParser.h +++ b/src/loaders/lottie/tvgLottieParser.h @@ -51,7 +51,6 @@ private: StrokeJoin getStrokeJoin(); CompositeMethod getMaskMethod(bool inversed); LottieInterpolator* getInterpolator(const char* key, Point& in, Point& out); - uint8_t getDirection(); void getInterpolatorPoint(Point& pt); void getPathSet(LottiePathSet& path); @@ -94,6 +93,7 @@ private: LottieFont* parseFont(); LottieMarker* parseMarker(); + bool parseDirection(LottieShape* shape, const char* key); bool parseCommon(LottieObject* obj, const char* key); void parseObject(Array& parent); void parseShapes(Array& parent);