mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
More matrix related clean-ups.
This commit is contained in:
parent
238f577e6f
commit
064d632d65
3 changed files with 9 additions and 10 deletions
|
@ -373,6 +373,10 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
&& this._tx === 0 && this._ty === 0;
|
||||
},
|
||||
|
||||
orNullIfIdentity: function() {
|
||||
return this.isIdentity() ? null : this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns whether the transform is invertible. A transform is not
|
||||
* invertible if the determinant is 0 or any value is non-finite or NaN.
|
||||
|
|
|
@ -829,7 +829,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// See if we can cache these bounds. We only cache the bounds
|
||||
// transformed with the internally stored _matrix, (the default if no
|
||||
// matrix is passed).
|
||||
var _matrix = this._matrix,
|
||||
matrix = matrix && matrix.orNullIfIdentity();
|
||||
var _matrix = this._matrix.orNullIfIdentity(),
|
||||
cache = (!matrix || matrix.equals(_matrix)) && getter;
|
||||
// Set up a boundsCache structure that keeps track of items that keep
|
||||
// cached bounds that depend on this item. We store this in our parent,
|
||||
|
@ -862,9 +863,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// If the result of concatinating the passed matrix with our internal
|
||||
// one is an identity transformation, set it to null for faster
|
||||
// processing
|
||||
if (_matrix.isIdentity())
|
||||
_matrix = null;
|
||||
matrix = !matrix || matrix.isIdentity()
|
||||
matrix = !matrix
|
||||
? _matrix
|
||||
: _matrix
|
||||
? matrix.clone().concatenate(_matrix)
|
||||
|
|
|
@ -67,14 +67,10 @@ var PathItem = Item.extend(/** @lends PathItem# */{
|
|||
var locations = [],
|
||||
curves1 = this.getCurves(),
|
||||
curves2 = path.getCurves(),
|
||||
matrix1 = this._matrix,
|
||||
matrix2 = path._matrix,
|
||||
matrix1 = this._matrix.orNullIfIdentity(),
|
||||
matrix2 = path._matrix.orNullIfIdentity(),
|
||||
length2 = curves2.length,
|
||||
values2 = [];
|
||||
if (matrix1.isIdentity())
|
||||
matrix1 = null;
|
||||
if (matrix2.isIdentity())
|
||||
matrix2 = null;
|
||||
for (var i = 0; i < length2; i++)
|
||||
values2[i] = curves2[i].getValues(matrix2);
|
||||
for (var i = 0, l = curves1.length; i < l; i++) {
|
||||
|
|
Loading…
Reference in a new issue