Use eslint, add travis-ci

This commit is contained in:
Horcrux
2016-05-04 17:54:30 +08:00
parent be8c273adf
commit cbce096b5c
41 changed files with 93 additions and 297 deletions

View File

@@ -1,3 +1,4 @@
import _ from 'lodash';
const MOVE_TO = 0;
const CLOSE = 1;
const LINE_TO = 2;
@@ -93,7 +94,7 @@ export default class SerializablePath {
};
lineTo = (x,y) => {
if (this.penDownX == null) {
if (_.isNil(this.penDownX)) {
this.penDownX = this.penX; this.penDownY = this.penY;
}
this.onLine(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
@@ -106,10 +107,10 @@ export default class SerializablePath {
return this.curveTo(
x + (+c1x), y + (+c1y),
c2x == null ? null : x + (+c2x),
c2y == null ? null : y + (+c2y),
ex == null ? null : x + (+ex),
ey == null ? null : y + (+ey)
_.isNil(c2x) ? null : x + (+c2x),
_.isNil(c2y) ? null : y + (+c2y),
_.isNil(ex) ? null : x + (+ex),
_.isNil(ey) ? null : y + (+ey)
);
};
@@ -117,12 +118,12 @@ export default class SerializablePath {
let x = this.penX,
y = this.penY;
if (c2x == null){
if (_.isNil(c2x)){
c2x = +c1x; c2y = +c1y;
c1x = (x * 2) - (this._pivotX || 0); c1y = (y * 2) - (this._pivotY || 0);
}
if (ex == null){
if (_.isNil(ex)){
this._pivotX = +c1x; this._pivotY = +c1y;
ex = +c2x; ey = +c2y;
c2x = (ex + (+c1x) * 2) / 3; c2y = (ey + (+c1y) * 2) / 3;
@@ -130,7 +131,7 @@ export default class SerializablePath {
} else {
this._pivotX = +c2x; this._pivotY = +c2y;
}
if (this.penDownX == null) {
if (_.isNil(this.penDownX)) {
this.penDownX = x; this.penDownY = y;
}
this.onBezierCurve(x, y, +c1x, +c1y, +c2x, +c2y, this.penX = +ex, this.penY = +ey);
@@ -145,7 +146,7 @@ export default class SerializablePath {
ry = Math.abs(+ry || +rx || (+y - this.penY));
rx = Math.abs(+rx || (+x - this.penX));
if (!rx || !ry || (x == this.penX && y == this.penY)) {
if (!rx || !ry || (x === this.penX && y === this.penY)) {
return this.lineTo(x, y);
}
@@ -168,7 +169,10 @@ export default class SerializablePath {
cx = x / 2; cy = y / 2;
} else {
a = Math.sqrt(a / (rxcy + rycx));
if (large == clockwise) a = -a;
if (large === clockwise) {
a = -a;
}
let cxd = -a * cy * rx / ry,
cyd = a * cx * ry / rx;
cx = cos * cxd - sin * cyd + x / 2;
@@ -187,7 +191,9 @@ export default class SerializablePath {
x += tX; y += tY;
// Circular Arc
if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
if (_.isNil(this.penDownX)) {
this.penDownX = this.penX; this.penDownY = this.penY;
}
this.onArc(
tX, tY, this._pivotX = this.penX = x, this._pivotY = this.penY = y,
cx, cy, rx, ry, sa, ea, !clockwise, rotation
@@ -204,7 +210,7 @@ export default class SerializablePath {
};
close = () => {
if (this.penDownX != null){
if (!_.isNil(this.penDownX)){
this.onClose(this.penX, this.penY, this.penX = this.penDownX, this.penY = this.penDownY);
this.penDownX = null;
}