fix lint warnings

This commit is contained in:
Horcrux
2016-07-27 12:10:12 +08:00
parent f2ee72bb76
commit 7d09dcde29
19 changed files with 54 additions and 61 deletions

View File

@@ -2,8 +2,8 @@
* based on
* https://github.com/CreateJS/EaselJS/blob/631cdffb85eff9413dab43b4676f059b4232d291/src/easeljs/geom/Matrix2D.js
*/
const DEG_TO_RAD = Math.PI/180;
import _ from 'lodash';
const DEG_TO_RAD = Math.PI / 180;
/**
* Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.
@@ -81,10 +81,10 @@ class Matrix2D {
*/
setTransform = function(a, b, c, d, tx, ty) {
// don't forget to update docs in the constructor if these change:
this.a = (a == null) ? 1 : a;
this.a = _.isNil(a) ? 1 : a;
this.b = b || 0;
this.c = c || 0;
this.d = (d == null) ? 1 : d;
this.d = _.isNil(d) ? 1 : d;
this.tx = tx || 0;
this.ty = ty || 0;
return this;
@@ -147,12 +147,12 @@ class Matrix2D {
var c1 = this.c;
var 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.tx = a*tx1+c*this.ty+tx;
this.ty = b*tx1+d*this.ty+ty;
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;
return this;
};
@@ -173,14 +173,14 @@ class Matrix2D {
var b1 = this.b;
var c1 = this.c;
var 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;
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.tx = a1*tx+c1*ty+this.tx;
this.ty = b1*tx+d1*ty+this.ty;
this.tx = a1 * tx + c1 * ty + this.tx;
this.ty = b1 * tx + d1 * ty + this.ty;
return this;
};
@@ -203,8 +203,8 @@ class Matrix2D {
* @return {Matrix2D} This matrix. Useful for chaining method calls.
**/
appendTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
if (rotation%360) {
var r = rotation*DEG_TO_RAD;
if (rotation % 360) {
var r = rotation * DEG_TO_RAD;
var cos = Math.cos(r);
var sin = Math.sin(r);
} else {
@@ -217,15 +217,15 @@ class Matrix2D {
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(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) {
// append the registration offset:
this.tx -= regX*this.a+regY*this.c;
this.ty -= regX*this.b+regY*this.d;
this.tx -= regX * this.a + regY * this.c;
this.ty -= regX * this.b + regY * this.d;
}
return this;
};
@@ -256,8 +256,8 @@ class Matrix2D {
* @return {Matrix2D} This matrix. Useful for chaining method calls.
**/
prependTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
if (rotation%360) {
var r = rotation*DEG_TO_RAD;
if (rotation % 360) {
var r = rotation * DEG_TO_RAD;
var cos = Math.cos(r);
var sin = Math.sin(r);
} else {
@@ -273,10 +273,10 @@ class Matrix2D {
// 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(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);
}
return this;
};