Update path.class.js

Like any other shape in fabric, when exported to svg, the shape has to be translated around origin.
This additional translation brings it there.

Fixes svg export of paths OUTSIDE of path-gropus. Inside was already ok.
This commit is contained in:
Andrea Bogazzi 2014-09-13 13:14:58 +02:00
parent 791c74a82e
commit 28784dc9b3

View file

@ -537,19 +537,21 @@
*/
toSVG: function(reviver) {
var chunks = [],
markup = this._createBaseSVGMarkup();
markup = this._createBaseSVGMarkup(), addTransform = '';
for (var i = 0, len = this.path.length; i < len; i++) {
chunks.push(this.path[i].join(' '));
}
var path = chunks.join(' ');
if (!(this.group && this.group.type == 'path-group')) {
addTransform = 'translate(' + (-this.width / 2) + ', ' + (-this.height / 2) + ')';
}
markup.push(
//jscs:disable validateIndentation
'<path ',
'd="', path,
'" style="', this.getSvgStyles(),
'" transform="', this.getSvgTransform(),
'" transform="', this.getSvgTransform(), addTransform,
this.getSvgTransformMatrix(), '" stroke-linecap="round" ',
'/>\n'
//jscs:enable validateIndentation