From fc0dd0377a80c8d9368fbabce08bb659e3c185ae Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 4 Jul 2014 11:13:55 +0100 Subject: [PATCH] ToSVG respects viewport transformation --- src/mixins/object.svg_export.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mixins/object.svg_export.js b/src/mixins/object.svg_export.js index 43717121..ba18e5fc 100644 --- a/src/mixins/object.svg_export.js +++ b/src/mixins/object.svg_export.js @@ -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) ' : '',