mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: chores++
This commit is contained in:
parent
2a4dfcd10e
commit
1d90608edc
1 changed files with 24 additions and 26 deletions
|
@ -38,30 +38,30 @@ static bool _buildComposition(LottieComposition* comp, LottieLayer* parent);
|
||||||
static bool _draw(LottieGroup* parent, LottieShape* shape, RenderContext* ctx);
|
static bool _draw(LottieGroup* parent, LottieShape* shape, RenderContext* ctx);
|
||||||
|
|
||||||
|
|
||||||
static void _rotationXYZ(Matrix* m, float degreeX, float degreeY, float degreeZ)
|
static void _rotate(LottieTransform* transform, float frameNo, Matrix& m, float angle, LottieExpressions* exps)
|
||||||
{
|
{
|
||||||
auto radianX = deg2rad(degreeX);
|
//rotation xyz
|
||||||
auto radianY = deg2rad(degreeY);
|
if (transform->rotationEx) {
|
||||||
auto radianZ = deg2rad(degreeZ);
|
auto radianX = deg2rad(transform->rotationEx->x(frameNo, exps));
|
||||||
|
auto radianY = deg2rad(transform->rotationEx->y(frameNo, exps));
|
||||||
|
auto radianZ = deg2rad(transform->rotation(frameNo, exps)) + angle;
|
||||||
auto cx = cosf(radianX), sx = sinf(radianX);
|
auto cx = cosf(radianX), sx = sinf(radianX);
|
||||||
auto cy = cosf(radianY), sy = sinf(radianY);;
|
auto cy = cosf(radianY), sy = sinf(radianY);;
|
||||||
auto cz = cosf(radianZ), sz = sinf(radianZ);;
|
auto cz = cosf(radianZ), sz = sinf(radianZ);;
|
||||||
m->e11 = cy * cz;
|
m.e11 = cy * cz;
|
||||||
m->e12 = -cy * sz;
|
m.e12 = -cy * sz;
|
||||||
m->e21 = sx * sy * cz + cx * sz;
|
m.e21 = sx * sy * cz + cx * sz;
|
||||||
m->e22 = -sx * sy * sz + cx * cz;
|
m.e22 = -sx * sy * sz + cx * cz;
|
||||||
}
|
//rotation z
|
||||||
|
} else {
|
||||||
|
auto degree = transform->rotation(frameNo, exps) + angle;
|
||||||
static void _rotationZ(Matrix* m, float degree)
|
|
||||||
{
|
|
||||||
if (degree == 0.0f) return;
|
if (degree == 0.0f) return;
|
||||||
auto radian = deg2rad(degree);
|
auto radian = deg2rad(degree);
|
||||||
m->e11 = cosf(radian);
|
m.e11 = cosf(radian);
|
||||||
m->e12 = -sinf(radian);
|
m.e12 = -sinf(radian);
|
||||||
m->e21 = sinf(radian);
|
m.e21 = sinf(radian);
|
||||||
m->e22 = cosf(radian);
|
m.e22 = cosf(radian);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,9 +115,7 @@ static bool _updateTransform(LottieTransform* transform, float frameNo, bool aut
|
||||||
|
|
||||||
auto angle = 0.0f;
|
auto angle = 0.0f;
|
||||||
if (autoOrient) angle = transform->position.angle(frameNo);
|
if (autoOrient) angle = transform->position.angle(frameNo);
|
||||||
if (transform->rotationEx) _rotationXYZ(&matrix, transform->rotationEx->x(frameNo, exps), transform->rotationEx->y(frameNo, exps), transform->rotation(frameNo, exps) + angle);
|
_rotate(transform, frameNo, matrix, angle, exps);
|
||||||
else _rotationZ(&matrix, transform->rotation(frameNo, exps) + angle);
|
|
||||||
|
|
||||||
|
|
||||||
auto skewAngle = transform->skewAngle(frameNo, exps);
|
auto skewAngle = transform->skewAngle(frameNo, exps);
|
||||||
if (skewAngle != 0.0f) {
|
if (skewAngle != 0.0f) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue