mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Fix issues with exporting SVG matrices when they can be resolved to simple rotate / scale / translate statements.
This commit is contained in:
parent
a36d244eb1
commit
d280d65f82
1 changed files with 11 additions and 8 deletions
|
@ -71,17 +71,20 @@ new function() {
|
||||||
// Note: getScaling() returns values also when it's not a simple scale,
|
// Note: getScaling() returns values also when it's not a simple scale,
|
||||||
// but angle is only != null if it is, so check for that.
|
// but angle is only != null if it is, so check for that.
|
||||||
var angle = matrix.getRotation(),
|
var angle = matrix.getRotation(),
|
||||||
scale = matrix.getScaling();
|
parts = [];
|
||||||
if (angle != null) {
|
if (angle != null) {
|
||||||
attrs.transform = (!trans || trans.isZero()
|
matrix = matrix.clone().scale(1, -1);
|
||||||
? ''
|
if (trans && !trans.isZero())
|
||||||
: 'translate(' + formatFloat(trans.x) + ', ' + formatFloat(trans.y) + ')')
|
parts.push('translate(' + formatPoint(trans) + ')');
|
||||||
+ (angle
|
if (angle)
|
||||||
? 'rotate(' + formatFloat(angle) + ')'
|
parts.push('rotate(' + formatFloat(angle) + ')');
|
||||||
: 'scale(' + formatPoint(scale) +')');
|
var scale = matrix.getScaling();
|
||||||
|
if (!Numerical.isZero(scale.x - 1) || !Numerical.isZero(scale.y - 1))
|
||||||
|
parts.push('scale(' + formatPoint(scale) +')');
|
||||||
} else {
|
} else {
|
||||||
attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')';
|
parts.push('matrix(' + matrix.getValues().join(',') + ')');
|
||||||
}
|
}
|
||||||
|
attrs.transform = parts.join(' ');
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue