mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
lottie: support 'direction' in ellipses
This commit is contained in:
parent
9ebc2045d6
commit
917917de7a
2 changed files with 19 additions and 12 deletions
|
@ -553,7 +553,7 @@ static void _updateRect(LottieGroup* parent, LottieObject** child, float frameNo
|
|||
}
|
||||
|
||||
|
||||
static void _appendCircle(Shape* shape, float cx, float cy, float rx, float ry, Matrix* transform)
|
||||
static void _appendCircle(Shape* shape, float cx, float cy, float rx, float ry, Matrix* transform, bool clockwise)
|
||||
{
|
||||
auto rxKappa = rx * PATH_KAPPA;
|
||||
auto ryKappa = ry * PATH_KAPPA;
|
||||
|
@ -565,13 +565,21 @@ static void _appendCircle(Shape* shape, float cx, float cy, float rx, float ry,
|
|||
};
|
||||
|
||||
constexpr int ptsCnt = 13;
|
||||
Point points[ptsCnt] = {
|
||||
{cx, cy - ry}, //moveTo
|
||||
{cx + rxKappa, cy - ry}, {cx + rx, cy - ryKappa}, {cx + rx, cy}, //cubicTo
|
||||
{cx + rx, cy + ryKappa}, {cx + rxKappa, cy + ry}, {cx, cy + ry}, //cubicTo
|
||||
{cx - rxKappa, cy + ry}, {cx - rx, cy + ryKappa}, {cx - rx, cy}, //cubicTo
|
||||
{cx - rx, cy - ryKappa}, {cx - rxKappa, cy - ry}, {cx, cy - ry} //cubicTo
|
||||
};
|
||||
Point points[ptsCnt];
|
||||
|
||||
if (clockwise) {
|
||||
points[0] = {cx, cy - ry}; //moveTo
|
||||
points[1] = {cx + rxKappa, cy - ry}; points[2] = {cx + rx, cy - ryKappa}; points[3] = {cx + rx, cy}; //cubicTo
|
||||
points[4] = {cx + rx, cy + ryKappa}; points[5] = {cx + rxKappa, cy + ry}; points[6] = {cx, cy + ry}; //cubicTo
|
||||
points[7] = {cx - rxKappa, cy + ry}; points[8] = {cx - rx, cy + ryKappa}; points[9] = {cx - rx, cy}; //cubicTo
|
||||
points[10] = {cx - rx, cy - ryKappa}; points[11] = {cx - rxKappa, cy - ry}; points[12] = {cx, cy - ry}; //cubicTo
|
||||
} else {
|
||||
points[0] = {cx, cy - ry}; //moveTo
|
||||
points[1] = {cx - rxKappa, cy - ry}; points[2] = {cx - rx, cy - ryKappa}; points[3] = {cx - rx, cy}; //cubicTo
|
||||
points[4] = {cx - rx, cy + ryKappa}; points[5] = {cx - rxKappa, cy + ry}; points[6] = {cx, cy + ry}; //cubicTo
|
||||
points[7] = {cx + rxKappa, cy + ry}; points[8] = {cx + rx, cy + ryKappa}; points[9] = {cx + rx, cy}; //cubicTo
|
||||
points[10] = {cx + rx, cy - ryKappa}; points[11] = {cx + rxKappa, cy - ry}; points[12] = {cx, cy - ry}; //cubicTo
|
||||
}
|
||||
|
||||
if (transform) {
|
||||
for (int i = 0; i < ptsCnt; ++i) {
|
||||
|
@ -592,11 +600,11 @@ static void _updateEllipse(LottieGroup* parent, LottieObject** child, float fram
|
|||
|
||||
if (!ctx->repeaters.empty()) {
|
||||
auto path = Shape::gen();
|
||||
_appendCircle(path.get(), position.x, position.y, size.x * 0.5f, size.y * 0.5f, ctx->transform);
|
||||
_appendCircle(path.get(), position.x, position.y, size.x * 0.5f, size.y * 0.5f, ctx->transform, ellipse->clockwise);
|
||||
_repeat(parent, std::move(path), ctx);
|
||||
} else {
|
||||
_draw(parent, ctx);
|
||||
_appendCircle(ctx->merging, position.x, position.y, size.x * 0.5f, size.y * 0.5f, ctx->transform);
|
||||
_appendCircle(ctx->merging, position.x, position.y, size.x * 0.5f, size.y * 0.5f, ctx->transform, ellipse->clockwise);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1088,8 +1088,7 @@ void LottieParser::parseTimeRemap(LottieLayer* layer)
|
|||
|
||||
uint8_t LottieParser::getDirection()
|
||||
{
|
||||
auto v = getInt();
|
||||
if (v == 3) return false;
|
||||
if (getInt() == 3) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue