|
@@ -683,32 +683,6 @@ static constexpr struct
|
|
|
};
|
|
|
|
|
|
|
|
|
-static void _matrixCompose(const Matrix* m1, const Matrix* m2, Matrix* dst)
|
|
|
-{
|
|
|
- auto a11 = (m1->e11 * m2->e11) + (m1->e12 * m2->e21) + (m1->e13 * m2->e31);
|
|
|
- auto a12 = (m1->e11 * m2->e12) + (m1->e12 * m2->e22) + (m1->e13 * m2->e32);
|
|
|
- auto a13 = (m1->e11 * m2->e13) + (m1->e12 * m2->e23) + (m1->e13 * m2->e33);
|
|
|
-
|
|
|
- auto a21 = (m1->e21 * m2->e11) + (m1->e22 * m2->e21) + (m1->e23 * m2->e31);
|
|
|
- auto a22 = (m1->e21 * m2->e12) + (m1->e22 * m2->e22) + (m1->e23 * m2->e32);
|
|
|
- auto a23 = (m1->e21 * m2->e13) + (m1->e22 * m2->e23) + (m1->e23 * m2->e33);
|
|
|
-
|
|
|
- auto a31 = (m1->e31 * m2->e11) + (m1->e32 * m2->e21) + (m1->e33 * m2->e31);
|
|
|
- auto a32 = (m1->e31 * m2->e12) + (m1->e32 * m2->e22) + (m1->e33 * m2->e32);
|
|
|
- auto a33 = (m1->e31 * m2->e13) + (m1->e32 * m2->e23) + (m1->e33 * m2->e33);
|
|
|
-
|
|
|
- dst->e11 = a11;
|
|
|
- dst->e12 = a12;
|
|
|
- dst->e13 = a13;
|
|
|
- dst->e21 = a21;
|
|
|
- dst->e22 = a22;
|
|
|
- dst->e23 = a23;
|
|
|
- dst->e31 = a31;
|
|
|
- dst->e32 = a32;
|
|
|
- dst->e33 = a33;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/* parse transform attribute
|
|
|
* https://www.w3.org/TR/SVG/coords.html#TransformAttribute
|
|
|
*/
|
|
@@ -751,14 +725,14 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
|
|
if (state == MatrixState::Matrix) {
|
|
|
if (ptCount != 6) goto error;
|
|
|
Matrix tmp = {points[0], points[2], points[4], points[1], points[3], points[5], 0, 0, 1};
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
} else if (state == MatrixState::Translate) {
|
|
|
if (ptCount == 1) {
|
|
|
Matrix tmp = {1, 0, points[0], 0, 1, 0, 0, 0, 1};
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
} else if (ptCount == 2) {
|
|
|
Matrix tmp = {1, 0, points[0], 0, 1, points[1], 0, 0, 1};
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
} else goto error;
|
|
|
} else if (state == MatrixState::Rotate) {
|
|
|
//Transform to signed.
|
|
@@ -768,14 +742,14 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
|
|
auto s = sinf(points[0] * (M_PI / 180.0));
|
|
|
if (ptCount == 1) {
|
|
|
Matrix tmp = { c, -s, 0, s, c, 0, 0, 0, 1 };
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
} else if (ptCount == 3) {
|
|
|
Matrix tmp = { 1, 0, points[1], 0, 1, points[2], 0, 0, 1 };
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
tmp = { c, -s, 0, s, c, 0, 0, 0, 1 };
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
tmp = { 1, 0, -points[1], 0, 1, -points[2], 0, 0, 1 };
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
} else {
|
|
|
goto error;
|
|
|
}
|
|
@@ -785,7 +759,17 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
|
|
auto sy = sx;
|
|
|
if (ptCount == 2) sy = points[1];
|
|
|
Matrix tmp = { sx, 0, 0, 0, sy, 0, 0, 0, 1 };
|
|
|
- _matrixCompose(matrix, &tmp, matrix);
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
+ } else if (state == MatrixState::SkewX) {
|
|
|
+ if (ptCount != 1) goto error;
|
|
|
+ auto deg = tanf(points[0] * (M_PI / 180.0));
|
|
|
+ Matrix tmp = { 1, deg, 0, 0, 1, 0, 0, 0, 1 };
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
+ } else if (state == MatrixState::SkewY) {
|
|
|
+ if (ptCount != 1) goto error;
|
|
|
+ auto deg = tanf(points[0] * (M_PI / 180.0));
|
|
|
+ Matrix tmp = { 1, 0, 0, deg, 1, 0, 0, 0, 1 };
|
|
|
+ *matrix = mathMultiply(matrix, &tmp);
|
|
|
}
|
|
|
}
|
|
|
return matrix;
|