mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
lottie: fix points calculation for rounded polygon
Added missing factor. issue: https://github.com/thorvg/thorvg/issues/2629
This commit is contained in:
parent
cd12618529
commit
6e41b44ea1
1 changed files with 6 additions and 10 deletions
|
@ -613,7 +613,7 @@ void LottieBuilder::updatePolygon(LottieGroup* parent, LottiePolyStar* star, flo
|
|||
auto radius = star->outerRadius(frameNo, tween, exps);
|
||||
auto outerRoundness = star->outerRoundness(frameNo, tween, exps) * 0.01f;
|
||||
|
||||
auto angle = deg2rad(-90.0f);
|
||||
auto angle = -MATH_PI2;
|
||||
auto anglePerPoint = 2.0f * MATH_PI / float(ptsCnt);
|
||||
auto direction = star->clockwise ? 1.0f : -1.0f;
|
||||
auto hasRoundness = !tvg::zero(outerRoundness);
|
||||
|
@ -641,6 +641,7 @@ void LottieBuilder::updatePolygon(LottieGroup* parent, LottiePolyStar* star, flo
|
|||
auto in = Point{x, y} * transform;
|
||||
shape->moveTo(in.x, in.y);
|
||||
|
||||
auto coeff = anglePerPoint * radius * outerRoundness * POLYGON_MAGIC_NUMBER;
|
||||
for (size_t i = 0; i < ptsCnt; i++) {
|
||||
auto previousX = x;
|
||||
auto previousY = y;
|
||||
|
@ -649,16 +650,11 @@ void LottieBuilder::updatePolygon(LottieGroup* parent, LottiePolyStar* star, flo
|
|||
|
||||
if (hasRoundness) {
|
||||
auto cp1Theta = tvg::atan2(previousY, previousX) - MATH_PI2 * direction;
|
||||
auto cp1Dx = cosf(cp1Theta);
|
||||
auto cp1Dy = sinf(cp1Theta);
|
||||
auto cp1x = coeff * cosf(cp1Theta);
|
||||
auto cp1y = coeff * sinf(cp1Theta);
|
||||
auto cp2Theta = tvg::atan2(y, x) - MATH_PI2 * direction;
|
||||
auto cp2Dx = cosf(cp2Theta);
|
||||
auto cp2Dy = sinf(cp2Theta);
|
||||
|
||||
auto cp1x = radius * outerRoundness * POLYGON_MAGIC_NUMBER * cp1Dx;
|
||||
auto cp1y = radius * outerRoundness * POLYGON_MAGIC_NUMBER * cp1Dy;
|
||||
auto cp2x = radius * outerRoundness * POLYGON_MAGIC_NUMBER * cp2Dx;
|
||||
auto cp2y = radius * outerRoundness * POLYGON_MAGIC_NUMBER * cp2Dy;
|
||||
auto cp2x = coeff * cosf(cp2Theta);
|
||||
auto cp2y = coeff * sinf(cp2Theta);
|
||||
|
||||
auto in2 = Point{previousX - cp1x, previousY - cp1y} * transform;
|
||||
auto in3 = Point{x + cp2x, y + cp2y} * transform;
|
||||
|
|
Loading…
Add table
Reference in a new issue