mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Shorten code a bit.
This commit is contained in:
parent
ad34bbf7aa
commit
541ac6acce
1 changed files with 19 additions and 18 deletions
|
@ -55,24 +55,25 @@ new function() {
|
||||||
attrs[center ? 'cy' : 'y'] = point.y;
|
attrs[center ? 'cy' : 'y'] = point.y;
|
||||||
trans = null;
|
trans = null;
|
||||||
}
|
}
|
||||||
if (matrix.isIdentity())
|
if (!matrix.isIdentity()) {
|
||||||
return attrs;
|
// See if we can decompose the matrix and can formulate it as a
|
||||||
// See if we can decompose the matrix and can formulate it as a simple
|
// simple translate/scale/rotate command sequence.
|
||||||
// translate/scale/rotate command sequence.
|
var decomposed = matrix.decompose();
|
||||||
var decomposed = matrix.decompose();
|
if (decomposed && !decomposed.shearing) {
|
||||||
if (decomposed && !decomposed.shearing) {
|
var parts = [],
|
||||||
var parts = [],
|
angle = decomposed.rotation,
|
||||||
angle = decomposed.rotation,
|
scale = decomposed.scaling;
|
||||||
scale = decomposed.scaling;
|
if (trans && !trans.isZero())
|
||||||
if (trans && !trans.isZero())
|
parts.push('translate(' + formatter.point(trans) + ')');
|
||||||
parts.push('translate(' + formatter.point(trans) + ')');
|
if (angle)
|
||||||
if (angle)
|
parts.push('rotate(' + formatter.number(angle) + ')');
|
||||||
parts.push('rotate(' + formatter.number(angle) + ')');
|
if (!Numerical.isZero(scale.x - 1)
|
||||||
if (!Numerical.isZero(scale.x - 1) || !Numerical.isZero(scale.y - 1))
|
|| !Numerical.isZero(scale.y - 1))
|
||||||
parts.push('scale(' + formatter.point(scale) +')');
|
parts.push('scale(' + formatter.point(scale) +')');
|
||||||
attrs.transform = parts.join(' ');
|
attrs.transform = parts.join(' ');
|
||||||
} else {
|
} else {
|
||||||
attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')';
|
attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue