mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-23 14:48:24 +00:00
Merge f8064f3b31
into 16604a873a
This commit is contained in:
commit
eacceab21f
2 changed files with 20 additions and 15 deletions
|
@ -393,12 +393,29 @@ static void _repeat(LottieGroup* parent, Shape* path, RenderContext* ctx)
|
|||
}
|
||||
|
||||
|
||||
static void _close(RenderPath& path, const Point& p, bool round, bool rect = false)
|
||||
{
|
||||
//the only case where the shape was truly closed via a 'close' command - change important for modifiers to ensure consistency with other cases
|
||||
if (rect) {
|
||||
if (!round) {
|
||||
path.pts.push(p);
|
||||
path.cmds.last() = PathCommand::LineTo;
|
||||
path.cmds.push(PathCommand::Close);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (round && tvg::zero(path.pts.last() - path.pts[path.pts.count - 2])) path.pts[path.pts.count - 2] = p;
|
||||
path.pts.last() = p;
|
||||
}
|
||||
|
||||
|
||||
void LottieBuilder::appendRect(Shape* shape, Point& pos, Point& size, float r, bool clockwise, RenderContext* ctx)
|
||||
{
|
||||
auto temp = (ctx->offset) ? Shape::gen() : shape;
|
||||
auto cnt = SHAPE(temp)->rs.path.pts.count;
|
||||
|
||||
temp->appendRect(pos.x, pos.y, size.x, size.y, r, r, clockwise);
|
||||
_close(SHAPE(temp)->rs.path, SHAPE(temp)->rs.path.pts[cnt], r > 0.0f, true);
|
||||
|
||||
if (ctx->transform) {
|
||||
for (auto i = cnt; i < SHAPE(temp)->rs.path.pts.count; ++i) {
|
||||
|
@ -490,13 +507,6 @@ void LottieBuilder::updatePath(LottieGroup* parent, LottieObject** child, float
|
|||
}
|
||||
|
||||
|
||||
static void _close(Array<Point>& pts, const Point& p, bool round)
|
||||
{
|
||||
if (round && tvg::zero(pts.last() - pts[pts.count - 2])) pts[pts.count - 2] = p;
|
||||
pts.last() = p;
|
||||
}
|
||||
|
||||
|
||||
void LottieBuilder::updateStar(LottiePolyStar* star, float frameNo, Matrix* transform, Shape* merging, RenderContext* ctx, Tween& tween, LottieExpressions* exps)
|
||||
{
|
||||
static constexpr auto POLYSTAR_MAGIC_NUMBER = 0.47829f / 0.28f;
|
||||
|
@ -605,7 +615,7 @@ void LottieBuilder::updateStar(LottiePolyStar* star, float frameNo, Matrix* tran
|
|||
longSegment = !longSegment;
|
||||
}
|
||||
//ensure proper shape closure - important for modifiers that behave differently for degenerate (linear) vs curved cubics
|
||||
_close(SHAPE(shape)->rs.path.pts, in, hasRoundness);
|
||||
_close(SHAPE(shape)->rs.path, in, hasRoundness);
|
||||
shape->close();
|
||||
|
||||
if (ctx->modifier) ctx->modifier->modifyPolystar(SHAPE(shape)->rs.path, SHAPE(merging)->rs.path, outerRoundness, hasRoundness);
|
||||
|
@ -675,7 +685,7 @@ void LottieBuilder::updatePolygon(LottieGroup* parent, LottiePolyStar* star, flo
|
|||
angle += anglePerPoint * direction;
|
||||
}
|
||||
//ensure proper shape closure - important for modifiers that behave differently for degenerate (linear) vs curved cubics
|
||||
_close(SHAPE(shape)->rs.path.pts, in, hasRoundness);
|
||||
_close(SHAPE(shape)->rs.path, in, hasRoundness);
|
||||
shape->close();
|
||||
|
||||
if (ctx->modifier) ctx->modifier->modifyPolystar(SHAPE(shape)->rs.path, SHAPE(merging)->rs.path, 0.0f, false);
|
||||
|
|
|
@ -349,12 +349,7 @@ bool LottieOffsetModifier::modifyPath(PathCommand* inCmds, uint32_t inCmdsCnt, P
|
|||
}
|
||||
|
||||
iPt += 3;
|
||||
}
|
||||
else {
|
||||
if (!tvg::zero(inPts[iPt - 1] - inPts[state.movetoInIndex])) {
|
||||
out.cmds.push(PathCommand::LineTo);
|
||||
corner(out, state.line, state.firstLine, state.movetoOutIndex, true);
|
||||
}
|
||||
} else {
|
||||
out.cmds.push(PathCommand::Close);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue