mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-16 04:54:39 +00:00
wg_engine: fix close command logic
On a close path command creates a new object started form the closed point issue: https://github.com/thorvg/thorvg/pull/2923
This commit is contained in:
parent
6d03def994
commit
505ebe9fe6
1 changed files with 16 additions and 4 deletions
|
@ -198,8 +198,7 @@ struct WgVertexBuffer
|
||||||
if (cmd == PathCommand::MoveTo) {
|
if (cmd == PathCommand::MoveTo) {
|
||||||
// after path decoding we need to update distances and total length
|
// after path decoding we need to update distances and total length
|
||||||
if (update_dist) updateDistances();
|
if (update_dist) updateDistances();
|
||||||
if ((onPolyline) && (vcount != 0))
|
if ((onPolyline) && (vcount > 0)) onPolyline(*this);
|
||||||
onPolyline(*this);
|
|
||||||
reset(tscale);
|
reset(tscale);
|
||||||
append(rshape.path.pts[pntIndex]);
|
append(rshape.path.pts[pntIndex]);
|
||||||
pntIndex++;
|
pntIndex++;
|
||||||
|
@ -208,15 +207,28 @@ struct WgVertexBuffer
|
||||||
pntIndex++;
|
pntIndex++;
|
||||||
} else if (cmd == PathCommand::Close) {
|
} else if (cmd == PathCommand::Close) {
|
||||||
close();
|
close();
|
||||||
|
// proceed path if close command is not the last command and next command is LineTo or CubicTo
|
||||||
|
if ((cmdIndex + 1 < rshape.path.cmds.count) &&
|
||||||
|
((rshape.path.cmds[cmdIndex + 1] == PathCommand::LineTo) ||
|
||||||
|
(rshape.path.cmds[cmdIndex + 1] == PathCommand::CubicTo))) {
|
||||||
|
// proceed current path
|
||||||
|
if (update_dist) updateDistances();
|
||||||
|
if ((vcount > 0) && (onPolyline)) onPolyline(*this);
|
||||||
|
// append closing point of current path as a first point of the new path
|
||||||
|
Point last_pt = last();
|
||||||
|
reset(tscale);
|
||||||
|
append(last_pt);
|
||||||
|
}
|
||||||
} else if (cmd == PathCommand::CubicTo) {
|
} else if (cmd == PathCommand::CubicTo) {
|
||||||
|
// append tesselated cubic spline with tscale param
|
||||||
appendCubic(vbuff[vcount - 1], rshape.path.pts[pntIndex + 0], rshape.path.pts[pntIndex + 1], rshape.path.pts[pntIndex + 2]);
|
appendCubic(vbuff[vcount - 1], rshape.path.pts[pntIndex + 0], rshape.path.pts[pntIndex + 1], rshape.path.pts[pntIndex + 2]);
|
||||||
pntIndex += 3;
|
pntIndex += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// after path decoding we need to update distances and total length
|
// after path decoding we need to update distances and total length
|
||||||
if (update_dist) updateDistances();
|
if (update_dist) updateDistances();
|
||||||
if ((onPolyline) && (vcount != 0))
|
if ((vcount > 0) && (onPolyline)) onPolyline(*this);
|
||||||
onPolyline(*this);
|
reset(tscale);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue