Fix issues with exporting SVG matrices when they can be resolved to simple rotate / scale / translate statements.

This commit is contained in:
Jürg Lehni 2012-12-15 02:20:37 -08:00
parent a36d244eb1
commit d280d65f82

View file

@ -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;
} }