mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
loader/lottie: filled a missing gradient stroke dash body.
This commit is contained in:
parent
204c87b470
commit
dae6636d29
5 changed files with 27 additions and 27 deletions
|
@ -29,8 +29,8 @@
|
|||
/* Drawing Commands */
|
||||
/************************************************************************/
|
||||
|
||||
#define NUM_PER_ROW 9
|
||||
#define NUM_PER_COL 9
|
||||
#define NUM_PER_ROW 10
|
||||
#define NUM_PER_COL 10
|
||||
#define SIZE (WIDTH/NUM_PER_ROW)
|
||||
|
||||
static int counter = 0;
|
||||
|
|
1
src/examples/images/intelia_logo_animation.json
Normal file
1
src/examples/images/intelia_logo_animation.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -134,7 +134,6 @@ static Shape* _updateGroup(LottieGroup* parent, LottieGroup* group, int32_t fram
|
|||
|
||||
static Shape* _updateFill(LottieSolidFill* fill, int32_t frameNo, Shape* baseShape)
|
||||
{
|
||||
if (fill->disabled) return nullptr;
|
||||
auto color = fill->color(frameNo);
|
||||
baseShape->fill(color.rgb[0], color.rgb[1], color.rgb[2], fill->opacity(frameNo));
|
||||
baseShape->fill(fill->rule);
|
||||
|
@ -142,18 +141,17 @@ static Shape* _updateFill(LottieSolidFill* fill, int32_t frameNo, Shape* baseSha
|
|||
}
|
||||
|
||||
|
||||
static Shape* _updateStroke(LottieSolidStroke* stroke, int32_t frameNo, Shape* baseShape)
|
||||
static Shape* _updateStroke(LottieStroke* stroke, int32_t frameNo, Shape* baseShape)
|
||||
{
|
||||
if (stroke->disabled) return nullptr;
|
||||
baseShape->stroke(stroke->width(frameNo));
|
||||
auto color = stroke->color(frameNo);
|
||||
baseShape->stroke(color.rgb[0], color.rgb[1], color.rgb[2], stroke->opacity(frameNo));
|
||||
baseShape->stroke(stroke->cap);
|
||||
baseShape->stroke(stroke->join);
|
||||
baseShape->strokeMiterlimit(stroke->miterLimit);
|
||||
|
||||
if (stroke->dashattr) {
|
||||
float dashes[2] = { stroke->dashSize(frameNo), stroke->dashGap(frameNo) };
|
||||
float dashes[2];
|
||||
dashes[0] = stroke->dashSize(frameNo);
|
||||
dashes[1] = dashes[0] + stroke->dashGap(frameNo);
|
||||
P(baseShape)->strokeDash(dashes, 2, stroke->dashOffset(frameNo));
|
||||
} else {
|
||||
baseShape->stroke(nullptr, 0);
|
||||
|
@ -163,24 +161,27 @@ static Shape* _updateStroke(LottieSolidStroke* stroke, int32_t frameNo, Shape* b
|
|||
}
|
||||
|
||||
|
||||
static Shape* _updateFill(LottieGradientFill* fill, int32_t frameNo, Shape* baseShape)
|
||||
static Shape* _updateStroke(LottieSolidStroke* stroke, int32_t frameNo, Shape* baseShape)
|
||||
{
|
||||
baseShape->opacity(fill->opacity(frameNo));
|
||||
//TODO: reuse the fill instance?
|
||||
baseShape->fill(unique_ptr<Fill>(fill->fill(frameNo)));
|
||||
baseShape->fill(fill->rule);
|
||||
return nullptr;
|
||||
auto color = stroke->color(frameNo);
|
||||
baseShape->stroke(color.rgb[0], color.rgb[1], color.rgb[2], stroke->opacity(frameNo));
|
||||
|
||||
return _updateStroke(static_cast<LottieStroke*>(stroke), frameNo, baseShape);
|
||||
}
|
||||
|
||||
|
||||
static Shape* _updateStroke(LottieGradientStroke* stroke, int32_t frameNo, Shape* baseShape)
|
||||
{
|
||||
baseShape->opacity(stroke->opacity(frameNo));
|
||||
baseShape->stroke(stroke->width(frameNo));
|
||||
baseShape->stroke(unique_ptr<Fill>(stroke->fill(frameNo)));
|
||||
baseShape->stroke(stroke->cap);
|
||||
baseShape->stroke(stroke->join);
|
||||
baseShape->strokeMiterlimit(stroke->miterLimit);
|
||||
return _updateStroke(static_cast<LottieStroke*>(stroke), frameNo, baseShape);
|
||||
}
|
||||
|
||||
|
||||
static Shape* _updateFill(LottieGradientFill* fill, int32_t frameNo, Shape* baseShape)
|
||||
{
|
||||
//TODO: reuse the fill instance?
|
||||
baseShape->fill(unique_ptr<Fill>(fill->fill(frameNo)));
|
||||
baseShape->fill(fill->rule);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ struct LottieStroke
|
|||
|
||||
float dashSize(int32_t frameNo)
|
||||
{
|
||||
return dash(1)(frameNo);
|
||||
auto d = dash(1)(frameNo);
|
||||
if (d == 0.0f) return 0.1f;
|
||||
else return d;
|
||||
}
|
||||
|
||||
bool dynamic()
|
||||
|
@ -82,7 +84,7 @@ struct LottieGradient
|
|||
{
|
||||
bool dynamic()
|
||||
{
|
||||
if (start.frames || end.frames || opacity.frames || height.frames || angle.frames || colorStops.frames) return true;
|
||||
if (start.frames || end.frames || height.frames || angle.frames || colorStops.frames) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -90,7 +92,6 @@ struct LottieGradient
|
|||
|
||||
LottiePoint start = Point{0.0f, 0.0f};
|
||||
LottiePoint end = Point{0.0f, 0.0f};
|
||||
LottieOpacity opacity = 255;
|
||||
LottieFloat height = 0.0f;
|
||||
LottieFloat angle = 0.0f;
|
||||
LottieColorStop colorStops;
|
||||
|
@ -285,7 +286,6 @@ struct LottieSolidStroke : LottieObject, LottieStroke
|
|||
|
||||
LottieColor color = RGB24{255, 255, 255};
|
||||
LottieOpacity opacity = 255;
|
||||
bool disabled = false; //TODO: can't replace with hidden?
|
||||
};
|
||||
|
||||
|
||||
|
@ -300,7 +300,6 @@ struct LottieSolidFill : LottieObject
|
|||
LottieColor color = RGB24{255, 255, 255};
|
||||
LottieOpacity opacity = 255;
|
||||
FillRule rule = FillRule::Winding;
|
||||
bool disabled = false; //TODO: can't replace with hidden?
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ LottieSolidFill* LottieParser::parseSolidFill()
|
|||
if (!strcmp(key, "nm")) fill->name = getStringCopy();
|
||||
else if (!strcmp(key, "c")) parseProperty(fill->color);
|
||||
else if (!strcmp(key, "o")) parseProperty(fill->opacity);
|
||||
else if (!strcmp(key, "fillEnabled")) fill->disabled = !getBool();
|
||||
else if (!strcmp(key, "fillEnabled")) fill->hidden |= !getBool();
|
||||
else if (!strcmp(key, "r")) fill->rule = getFillRule();
|
||||
else if (!strcmp(key, "hd")) fill->hidden = getBool();
|
||||
else skip(key);
|
||||
|
@ -590,7 +590,7 @@ LottieSolidStroke* LottieParser::parseSolidStroke()
|
|||
else if (!strcmp(key, "ml")) stroke->miterLimit = getFloat();
|
||||
else if (!strcmp(key, "nm")) stroke->name = getStringCopy();
|
||||
else if (!strcmp(key, "hd")) stroke->hidden = getBool();
|
||||
else if (!strcmp(key, "fillEnabled")) stroke->disabled = !getBool();
|
||||
else if (!strcmp(key, "fillEnabled")) stroke->hidden |= !getBool();
|
||||
else if (!strcmp(key, "d")) parseStrokeDash(stroke);
|
||||
else skip(key);
|
||||
}
|
||||
|
@ -681,7 +681,6 @@ LottieRoundedCorner* LottieParser::parseRoundedCorner()
|
|||
void LottieParser::parseGradient(LottieGradient* gradient, const char* key)
|
||||
{
|
||||
if (!strcmp(key, "t")) gradient->id = getInt();
|
||||
else if (!strcmp(key, "o")) parseProperty(gradient->opacity);
|
||||
else if (!strcmp(key, "g"))
|
||||
{
|
||||
enterObject();
|
||||
|
|
Loading…
Add table
Reference in a new issue