ToSVG respects viewport transformation

This commit is contained in:
Tom French 2014-07-04 11:13:55 +01:00
parent 77811aa4bc
commit fc0dd0377a

View file

@ -47,6 +47,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
var toFixed = fabric.util.toFixed,
angle = this.getAngle(),
center = this.getCenterPoint(),
vpt = this.getViewportTransform();
center = fabric.util.transformPoint(center, vpt);
NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS,
@ -63,9 +66,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
scalePart = (this.scaleX === 1 && this.scaleY === 1)
? '' :
(' scale(' +
toFixed(this.scaleX, NUM_FRACTION_DIGITS) +
toFixed(this.scaleX * vpt[0], NUM_FRACTION_DIGITS) +
' ' +
toFixed(this.scaleY, NUM_FRACTION_DIGITS) +
toFixed(this.scaleY * vpt[3], NUM_FRACTION_DIGITS) +
')'),
flipXPart = this.flipX ? 'matrix(-1 0 0 1 0 0) ' : '',