mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-21 14:25:14 +00:00
Run Prettier, configure ESLint.
This commit is contained in:
112
lib/Matrix2D.js
112
lib/Matrix2D.js
@@ -119,7 +119,14 @@ export default class Matrix2D {
|
||||
*/
|
||||
copy = function(matrix) {
|
||||
//noinspection JSUnresolvedVariable
|
||||
return this.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
|
||||
return this.setTransform(
|
||||
matrix.a,
|
||||
matrix.b,
|
||||
matrix.c,
|
||||
matrix.d,
|
||||
matrix.tx,
|
||||
matrix.ty
|
||||
);
|
||||
};
|
||||
|
||||
//noinspection JSUnusedGlobalSymbols
|
||||
@@ -150,10 +157,10 @@ export default class Matrix2D {
|
||||
const c1 = this.c;
|
||||
const tx1 = this.tx;
|
||||
|
||||
this.a = a * a1 + c * this.b;
|
||||
this.b = b * a1 + d * this.b;
|
||||
this.c = a * c1 + c * this.d;
|
||||
this.d = b * c1 + d * this.d;
|
||||
this.a = a * a1 + c * this.b;
|
||||
this.b = b * a1 + d * this.b;
|
||||
this.c = a * c1 + c * this.d;
|
||||
this.d = b * c1 + d * this.d;
|
||||
this.tx = a * tx1 + c * this.ty + tx;
|
||||
this.ty = b * tx1 + d * this.ty + ty;
|
||||
//noinspection JSValidateTypes
|
||||
@@ -178,10 +185,10 @@ export default class Matrix2D {
|
||||
const c1 = this.c;
|
||||
const d1 = this.d;
|
||||
if (a !== 1 || b !== 0 || c !== 0 || d !== 1) {
|
||||
this.a = a1 * a + c1 * b;
|
||||
this.b = b1 * a + d1 * b;
|
||||
this.c = a1 * c + c1 * d;
|
||||
this.d = b1 * c + d1 * d;
|
||||
this.a = a1 * a + c1 * b;
|
||||
this.b = b1 * a + d1 * b;
|
||||
this.c = a1 * c + c1 * d;
|
||||
this.d = b1 * c + d1 * d;
|
||||
}
|
||||
this.tx = a1 * tx + c1 * ty + this.tx;
|
||||
this.ty = b1 * tx + d1 * ty + this.ty;
|
||||
@@ -207,7 +214,17 @@ export default class Matrix2D {
|
||||
* @param {Number} regY Optional.
|
||||
* @return {Matrix2D} This matrix. Useful for chaining method calls.
|
||||
**/
|
||||
appendTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
|
||||
appendTransform = function(
|
||||
x,
|
||||
y,
|
||||
scaleX,
|
||||
scaleY,
|
||||
rotation,
|
||||
skewX,
|
||||
skewY,
|
||||
regX,
|
||||
regY
|
||||
) {
|
||||
let cos, sin;
|
||||
if (rotation % 360) {
|
||||
const r = rotation * DEG_TO_RAD;
|
||||
@@ -222,10 +239,31 @@ export default class Matrix2D {
|
||||
// TODO: can this be combined into a single append operation?
|
||||
skewX *= DEG_TO_RAD;
|
||||
skewY *= DEG_TO_RAD;
|
||||
this.append(Math.cos(skewY), Math.sin(skewY), Math.sin(skewX), Math.cos(skewX), x, y);
|
||||
this.append(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, 0, 0);
|
||||
this.append(
|
||||
Math.cos(skewY),
|
||||
Math.sin(skewY),
|
||||
Math.sin(skewX),
|
||||
Math.cos(skewX),
|
||||
x,
|
||||
y
|
||||
);
|
||||
this.append(
|
||||
cos * scaleX,
|
||||
sin * scaleX,
|
||||
-sin * scaleY,
|
||||
cos * scaleY,
|
||||
0,
|
||||
0
|
||||
);
|
||||
} else {
|
||||
this.append(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, x, y);
|
||||
this.append(
|
||||
cos * scaleX,
|
||||
sin * scaleX,
|
||||
-sin * scaleY,
|
||||
cos * scaleY,
|
||||
x,
|
||||
y
|
||||
);
|
||||
}
|
||||
|
||||
if (regX || regY) {
|
||||
@@ -245,9 +283,9 @@ export default class Matrix2D {
|
||||
* var o = myDisplayObject;
|
||||
* var mtx = new createjs.Matrix2D();
|
||||
* do {
|
||||
* // prepend each parent's transformation in turn:
|
||||
* mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
|
||||
* } while (o = o.parent);
|
||||
* // prepend each parent's transformation in turn:
|
||||
* mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
|
||||
* } while (o = o.parent);
|
||||
*
|
||||
* Note that the above example would not account for {{#crossLink "DisplayObject/transformMatrix:property"}}{{/crossLink}}
|
||||
* values. See {{#crossLink "Matrix2D/prependMatrix"}}{{/crossLink}} for an example that does.
|
||||
@@ -263,7 +301,17 @@ export default class Matrix2D {
|
||||
* @param {Number} regY Optional.
|
||||
* @return {Matrix2D} This matrix. Useful for chaining method calls.
|
||||
**/
|
||||
prependTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
|
||||
prependTransform = function(
|
||||
x,
|
||||
y,
|
||||
scaleX,
|
||||
scaleY,
|
||||
rotation,
|
||||
skewX,
|
||||
skewY,
|
||||
regX,
|
||||
regY
|
||||
) {
|
||||
let cos, sin;
|
||||
if (rotation % 360) {
|
||||
const r = rotation * DEG_TO_RAD;
|
||||
@@ -276,16 +324,38 @@ export default class Matrix2D {
|
||||
|
||||
if (regX || regY) {
|
||||
// prepend the registration offset:
|
||||
this.tx -= regX; this.ty -= regY;
|
||||
this.tx -= regX;
|
||||
this.ty -= regY;
|
||||
}
|
||||
if (skewX || skewY) {
|
||||
// TODO: can this be combined into a single prepend operation?
|
||||
skewX *= DEG_TO_RAD;
|
||||
skewY *= DEG_TO_RAD;
|
||||
this.prepend(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, 0, 0);
|
||||
this.prepend(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
|
||||
this.prepend(
|
||||
cos * scaleX,
|
||||
sin * scaleX,
|
||||
-sin * scaleY,
|
||||
cos * scaleY,
|
||||
0,
|
||||
0
|
||||
);
|
||||
this.prepend(
|
||||
Math.cos(skewY),
|
||||
Math.sin(skewY),
|
||||
-Math.sin(skewX),
|
||||
Math.cos(skewX),
|
||||
x,
|
||||
y
|
||||
);
|
||||
} else {
|
||||
this.prepend(cos * scaleX, sin * scaleX, -sin * scaleY, cos * scaleY, x, y);
|
||||
this.prepend(
|
||||
cos * scaleX,
|
||||
sin * scaleX,
|
||||
-sin * scaleY,
|
||||
cos * scaleY,
|
||||
x,
|
||||
y
|
||||
);
|
||||
}
|
||||
//noinspection JSValidateTypes
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user