mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Streamline various #equals() methods.
This commit is contained in:
parent
4a8469b740
commit
2196ef2a74
5 changed files with 13 additions and 8 deletions
|
@ -110,8 +110,10 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
* @return {Boolean} {@true if the matrices are equal}
|
||||
*/
|
||||
equals: function(mx) {
|
||||
return mx && this._a == mx._a && this._b == mx._b && this._c == mx._c
|
||||
&& this._d == mx._d && this._tx == mx._tx && this._ty == mx._ty;
|
||||
return mx === this || mx && this._a == mx._a && this._b == mx._b
|
||||
&& this._c == mx._c && this._d == mx._d && this._tx == mx._tx
|
||||
&& this._ty == mx._ty
|
||||
|| false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,7 +105,7 @@ Base.inject(/** @lends Base# */{
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
if (obj1 == obj2)
|
||||
if (obj1 === obj2)
|
||||
return true;
|
||||
// Call #equals() on both obj1 and obj2
|
||||
if (obj1 && obj1.equals)
|
||||
|
|
|
@ -416,7 +416,8 @@ var Segment = Base.extend(/** @lends Segment# */{
|
|||
return segment === this || segment
|
||||
&& this._point.equals(segment._point)
|
||||
&& this._handleIn.equals(segment._handleIn)
|
||||
&& this._handleOut.equals(segment._handleOut);
|
||||
&& this._handleOut.equals(segment._handleOut)
|
||||
|| false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -699,9 +699,10 @@ var Color = Base.extend(new function() {
|
|||
equals: function(color) {
|
||||
if (Base.isPlainValue(color))
|
||||
color = Color.read(arguments);
|
||||
return color && this._type === color._type
|
||||
return color === this || color && this._type === color._type
|
||||
&& this._alpha === color._alpha
|
||||
&& Base.equals(this._components, color._components);
|
||||
&& Base.equals(this._components, color._components)
|
||||
|| false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -172,8 +172,9 @@ var GradientStop = Base.extend(/** @lends GradientStop# */{
|
|||
},
|
||||
|
||||
equals: function(stop) {
|
||||
return stop == this || stop instanceof GradientStop
|
||||
return stop === this || stop instanceof GradientStop
|
||||
&& this._color.equals(stop._color)
|
||||
&& this._rampPoint == stop._rampPoint;
|
||||
&& this._rampPoint == stop._rampPoint
|
||||
|| false;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue