diff --git a/inc/thorvg.h b/inc/thorvg.h index 48616cc2..6443ae62 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -124,8 +124,8 @@ enum class PathCommand : uint8_t enum class StrokeCap : uint8_t { Square = 0, ///< The stroke is extended in both end-points of a sub-path by a rectangle, with the width equal to the stroke width and the length equal to the half of the stroke width. For zero length sub-paths the square is rendered with the size of the stroke width. - Round, ///< The stroke is extended in both end-points of a sub-path by a half circle, with a radius equal to the half of a stroke width. For zero length sub-paths a full circle is rendered. - Butt ///< The stroke ends exactly at each of the two end-points of a sub-path. For zero length sub-paths no stroke is rendered. + Butt, ///< The stroke ends exactly at each of the two end-points of a sub-path. For zero length sub-paths no stroke is rendered. + Round ///< The stroke is extended in both end-points of a sub-path by a half circle, with a radius equal to the half of a stroke width. For zero length sub-paths a full circle is rendered. }; @@ -135,8 +135,8 @@ enum class StrokeCap : uint8_t enum class StrokeJoin : uint8_t { Bevel = 0, ///< The outer corner of the joined path segments is bevelled at the join point. The triangular region of the corner is enclosed by a straight line between the outer corners of each stroke. - Round, ///< The outer corner of the joined path segments is rounded. The circular region is centered at the join point. - Miter ///< The outer corner of the joined path segments is spiked. The spike is created by extension beyond the join point of the outer edges of the stroke until they intersect. In case the extension goes beyond the limit, the join style is converted to the Bevel style. + Miter, ///< The outer corner of the joined path segments is spiked. The spike is created by extension beyond the join point of the outer edges of the stroke until they intersect. In case the extension goes beyond the limit, the join style is converted to the Bevel style. + Round ///< The outer corner of the joined path segments is rounded. The circular region is centered at the join point. }; diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 99a11b42..b940302b 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -246,8 +246,8 @@ enum { */ typedef enum { TVG_STROKE_CAP_SQUARE = 0, ///< The stroke is extended in both endpoints of a sub-path by a rectangle, with the width equal to the stroke width and the length equal to the half of the stroke width. For zero length sub-paths the square is rendered with the size of the stroke width. - TVG_STROKE_CAP_ROUND, ///< The stroke is extended in both endpoints of a sub-path by a half circle, with a radius equal to the half of a stroke width. For zero length sub-paths a full circle is rendered. - TVG_STROKE_CAP_BUTT ///< The stroke ends exactly at each of the two endpoints of a sub-path. For zero length sub-paths no stroke is rendered. + TVG_STROKE_CAP_BUTT, ///< The stroke ends exactly at each of the two endpoints of a sub-path. For zero length sub-paths no stroke is rendered. + TVG_STROKE_CAP_ROUND ///< The stroke is extended in both endpoints of a sub-path by a half circle, with a radius equal to the half of a stroke width. For zero length sub-paths a full circle is rendered. } Tvg_Stroke_Cap; @@ -256,8 +256,8 @@ typedef enum { */ typedef enum { TVG_STROKE_JOIN_BEVEL = 0, ///< The outer corner of the joined path segments is bevelled at the join point. The triangular region of the corner is enclosed by a straight line between the outer corners of each stroke. - TVG_STROKE_JOIN_ROUND, ///< The outer corner of the joined path segments is rounded. The circular region is centered at the join point. - TVG_STROKE_JOIN_MITER ///< The outer corner of the joined path segments is spiked. The spike is created by extension beyond the join point of the outer edges of the stroke until they intersect. In case the extension goes beyond the limit, the join style is converted to the Bevel style. + TVG_STROKE_JOIN_MITER, ///< The outer corner of the joined path segments is spiked. The spike is created by extension beyond the join point of the outer edges of the stroke until they intersect. In case the extension goes beyond the limit, the join style is converted to the Bevel style. + TVG_STROKE_JOIN_ROUND ///< The outer corner of the joined path segments is rounded. The circular region is centered at the join point. } Tvg_Stroke_Join; diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index 8cdf923f..56702f79 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -119,47 +119,6 @@ RGB24 LottieParser::getColor(const char *str) } -FillRule LottieParser::getFillRule() -{ - switch (getInt()) { - case 1: return FillRule::NonZero; - default: return FillRule::EvenOdd; - } -} - - -MaskMethod LottieParser::getMatteType() -{ - switch (getInt()) { - case 1: return MaskMethod::Alpha; - case 2: return MaskMethod::InvAlpha; - case 3: return MaskMethod::Luma; - case 4: return MaskMethod::InvLuma; - default: return MaskMethod::None; - } -} - - -StrokeCap LottieParser::getStrokeCap() -{ - switch (getInt()) { - case 1: return StrokeCap::Butt; - case 2: return StrokeCap::Round; - default: return StrokeCap::Square; - } -} - - -StrokeJoin LottieParser::getStrokeJoin() -{ - switch (getInt()) { - case 1: return StrokeJoin::Miter; - case 2: return StrokeJoin::Round; - default: return StrokeJoin::Bevel; - } -} - - bool LottieParser::getValue(TextDocument& doc) { enterObject(); @@ -638,7 +597,7 @@ LottieSolidFill* LottieParser::parseSolidFill() else if (KEY_AS("c")) parseProperty(fill->color, fill); else if (KEY_AS("o")) parseProperty(fill->opacity, fill); else if (KEY_AS("fillEnabled")) fill->hidden |= !getBool(); - else if (KEY_AS("r")) fill->rule = getFillRule(); + else if (KEY_AS("r")) fill->rule = (getInt() == 1) ? FillRule::NonZero : FillRule::EvenOdd; else skip(); } return fill; @@ -676,8 +635,8 @@ LottieSolidStroke* LottieParser::parseSolidStroke() else if (KEY_AS("c")) parseProperty(stroke->color, stroke); else if (KEY_AS("o")) parseProperty(stroke->opacity, stroke); else if (KEY_AS("w")) parseProperty(stroke->width, stroke); - else if (KEY_AS("lc")) stroke->cap = getStrokeCap(); - else if (KEY_AS("lj")) stroke->join = getStrokeJoin(); + else if (KEY_AS("lc")) stroke->cap = (StrokeCap) getInt(); + else if (KEY_AS("lj")) stroke->join = (StrokeJoin) getInt(); else if (KEY_AS("ml")) stroke->miterLimit = getFloat(); else if (KEY_AS("fillEnabled")) stroke->hidden |= !getBool(); else if (KEY_AS("d")) parseStrokeDash(stroke); @@ -791,7 +750,7 @@ LottieGradientFill* LottieParser::parseGradientFill() while (auto key = nextObjectKey()) { if (parseCommon(fill, key)) continue; - else if (KEY_AS("r")) fill->rule = getFillRule(); + else if (KEY_AS("r")) fill->rule = (getInt() == 1) ? FillRule::NonZero : FillRule::EvenOdd; else parseGradient(fill, key); } @@ -809,8 +768,8 @@ LottieGradientStroke* LottieParser::parseGradientStroke() while (auto key = nextObjectKey()) { if (parseCommon(stroke, key)) continue; - else if (KEY_AS("lc")) stroke->cap = getStrokeCap(); - else if (KEY_AS("lj")) stroke->join = getStrokeJoin(); + else if (KEY_AS("lc")) stroke->cap = (StrokeCap) getInt(); + else if (KEY_AS("lj")) stroke->join = (StrokeJoin) getInt(); else if (KEY_AS("ml")) stroke->miterLimit = getFloat(); else if (KEY_AS("w")) parseProperty(stroke->width); else if (KEY_AS("d")) parseStrokeDash(stroke); @@ -879,7 +838,7 @@ LottieOffsetPath* LottieParser::parseOffsetPath() while (auto key = nextObjectKey()) { if (parseCommon(offsetPath, key)) continue; else if (KEY_AS("a")) parseProperty(offsetPath->offset); - else if (KEY_AS("lj")) offsetPath->join = getStrokeJoin(); + else if (KEY_AS("lj")) offsetPath->join = (StrokeJoin) getInt(); else if (KEY_AS("ml")) parseProperty(offsetPath->miterLimit); else skip(); } @@ -1508,7 +1467,7 @@ LottieLayer* LottieParser::parseLayer(LottieLayer* precomp) else if (KEY_AS("w") || KEY_AS("sw")) getLayerSize(layer->w); else if (KEY_AS("h") || KEY_AS("sh")) getLayerSize(layer->h); else if (KEY_AS("sc")) color = getColor(getString()); - else if (KEY_AS("tt")) layer->matteType = getMatteType(); + else if (KEY_AS("tt")) layer->matteType = (MaskMethod) getInt(); else if (KEY_AS("tp")) layer->mid = getInt(); else if (KEY_AS("masksProperties")) parseMasks(layer); else if (KEY_AS("hd")) layer->hidden = getBool(); diff --git a/src/loaders/lottie/tvgLottieParser.h b/src/loaders/lottie/tvgLottieParser.h index 0ed53908..94dc71d7 100644 --- a/src/loaders/lottie/tvgLottieParser.h +++ b/src/loaders/lottie/tvgLottieParser.h @@ -47,10 +47,7 @@ public: private: RGB24 getColor(const char *str); - MaskMethod getMatteType(); FillRule getFillRule(); - StrokeCap getStrokeCap(); - StrokeJoin getStrokeJoin(); MaskMethod getMaskMethod(bool inversed); LottieInterpolator* getInterpolator(const char* key, Point& in, Point& out); LottieEffect* getEffect(int type);