mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
api: aligned enum values with the lottie spec
Please note that this could occur ABI break.
This commit is contained in:
parent
0e9bc74603
commit
75a4c7f543
4 changed files with 16 additions and 60 deletions
|
@ -124,8 +124,8 @@ enum class PathCommand : uint8_t
|
||||||
enum class StrokeCap : 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.
|
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
|
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.
|
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.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -246,8 +246,8 @@ enum {
|
||||||
*/
|
*/
|
||||||
typedef 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_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;
|
} Tvg_Stroke_Cap;
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,8 +256,8 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
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_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;
|
} Tvg_Stroke_Join;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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)
|
bool LottieParser::getValue(TextDocument& doc)
|
||||||
{
|
{
|
||||||
enterObject();
|
enterObject();
|
||||||
|
@ -638,7 +597,7 @@ LottieSolidFill* LottieParser::parseSolidFill()
|
||||||
else if (KEY_AS("c")) parseProperty<LottieProperty::Type::Color>(fill->color, fill);
|
else if (KEY_AS("c")) parseProperty<LottieProperty::Type::Color>(fill->color, fill);
|
||||||
else if (KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(fill->opacity, fill);
|
else if (KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(fill->opacity, fill);
|
||||||
else if (KEY_AS("fillEnabled")) fill->hidden |= !getBool();
|
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();
|
else skip();
|
||||||
}
|
}
|
||||||
return fill;
|
return fill;
|
||||||
|
@ -676,8 +635,8 @@ LottieSolidStroke* LottieParser::parseSolidStroke()
|
||||||
else if (KEY_AS("c")) parseProperty<LottieProperty::Type::Color>(stroke->color, stroke);
|
else if (KEY_AS("c")) parseProperty<LottieProperty::Type::Color>(stroke->color, stroke);
|
||||||
else if (KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(stroke->opacity, stroke);
|
else if (KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(stroke->opacity, stroke);
|
||||||
else if (KEY_AS("w")) parseProperty<LottieProperty::Type::Float>(stroke->width, stroke);
|
else if (KEY_AS("w")) parseProperty<LottieProperty::Type::Float>(stroke->width, stroke);
|
||||||
else if (KEY_AS("lc")) stroke->cap = getStrokeCap();
|
else if (KEY_AS("lc")) stroke->cap = (StrokeCap) getInt();
|
||||||
else if (KEY_AS("lj")) stroke->join = getStrokeJoin();
|
else if (KEY_AS("lj")) stroke->join = (StrokeJoin) getInt();
|
||||||
else if (KEY_AS("ml")) stroke->miterLimit = getFloat();
|
else if (KEY_AS("ml")) stroke->miterLimit = getFloat();
|
||||||
else if (KEY_AS("fillEnabled")) stroke->hidden |= !getBool();
|
else if (KEY_AS("fillEnabled")) stroke->hidden |= !getBool();
|
||||||
else if (KEY_AS("d")) parseStrokeDash(stroke);
|
else if (KEY_AS("d")) parseStrokeDash(stroke);
|
||||||
|
@ -791,7 +750,7 @@ LottieGradientFill* LottieParser::parseGradientFill()
|
||||||
|
|
||||||
while (auto key = nextObjectKey()) {
|
while (auto key = nextObjectKey()) {
|
||||||
if (parseCommon(fill, key)) continue;
|
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);
|
else parseGradient(fill, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,8 +768,8 @@ LottieGradientStroke* LottieParser::parseGradientStroke()
|
||||||
|
|
||||||
while (auto key = nextObjectKey()) {
|
while (auto key = nextObjectKey()) {
|
||||||
if (parseCommon(stroke, key)) continue;
|
if (parseCommon(stroke, key)) continue;
|
||||||
else if (KEY_AS("lc")) stroke->cap = getStrokeCap();
|
else if (KEY_AS("lc")) stroke->cap = (StrokeCap) getInt();
|
||||||
else if (KEY_AS("lj")) stroke->join = getStrokeJoin();
|
else if (KEY_AS("lj")) stroke->join = (StrokeJoin) getInt();
|
||||||
else if (KEY_AS("ml")) stroke->miterLimit = getFloat();
|
else if (KEY_AS("ml")) stroke->miterLimit = getFloat();
|
||||||
else if (KEY_AS("w")) parseProperty<LottieProperty::Type::Float>(stroke->width);
|
else if (KEY_AS("w")) parseProperty<LottieProperty::Type::Float>(stroke->width);
|
||||||
else if (KEY_AS("d")) parseStrokeDash(stroke);
|
else if (KEY_AS("d")) parseStrokeDash(stroke);
|
||||||
|
@ -879,7 +838,7 @@ LottieOffsetPath* LottieParser::parseOffsetPath()
|
||||||
while (auto key = nextObjectKey()) {
|
while (auto key = nextObjectKey()) {
|
||||||
if (parseCommon(offsetPath, key)) continue;
|
if (parseCommon(offsetPath, key)) continue;
|
||||||
else if (KEY_AS("a")) parseProperty<LottieProperty::Type::Float>(offsetPath->offset);
|
else if (KEY_AS("a")) parseProperty<LottieProperty::Type::Float>(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<LottieProperty::Type::Float>(offsetPath->miterLimit);
|
else if (KEY_AS("ml")) parseProperty<LottieProperty::Type::Float>(offsetPath->miterLimit);
|
||||||
else skip();
|
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("w") || KEY_AS("sw")) getLayerSize(layer->w);
|
||||||
else if (KEY_AS("h") || KEY_AS("sh")) getLayerSize(layer->h);
|
else if (KEY_AS("h") || KEY_AS("sh")) getLayerSize(layer->h);
|
||||||
else if (KEY_AS("sc")) color = getColor(getString());
|
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("tp")) layer->mid = getInt();
|
||||||
else if (KEY_AS("masksProperties")) parseMasks(layer);
|
else if (KEY_AS("masksProperties")) parseMasks(layer);
|
||||||
else if (KEY_AS("hd")) layer->hidden = getBool();
|
else if (KEY_AS("hd")) layer->hidden = getBool();
|
||||||
|
|
|
@ -47,10 +47,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RGB24 getColor(const char *str);
|
RGB24 getColor(const char *str);
|
||||||
MaskMethod getMatteType();
|
|
||||||
FillRule getFillRule();
|
FillRule getFillRule();
|
||||||
StrokeCap getStrokeCap();
|
|
||||||
StrokeJoin getStrokeJoin();
|
|
||||||
MaskMethod getMaskMethod(bool inversed);
|
MaskMethod getMaskMethod(bool inversed);
|
||||||
LottieInterpolator* getInterpolator(const char* key, Point& in, Point& out);
|
LottieInterpolator* getInterpolator(const char* key, Point& in, Point& out);
|
||||||
LottieEffect* getEffect(int type);
|
LottieEffect* getEffect(int type);
|
||||||
|
|
Loading…
Add table
Reference in a new issue