diff --git a/src/gradient.class.js b/src/gradient.class.js index 1943a8f32f5..665c67a8299 100644 --- a/src/gradient.class.js +++ b/src/gradient.class.js @@ -173,18 +173,22 @@ toSVG: function(object) { var coords = clone(this.coords, true), i, len, markup, commonAttributes, colorStops = clone(this.colorStops, true), - needsSwap = coords.r1 > coords.r2; + needsSwap = coords.r1 > coords.r2, + offsetX = object.width / 2, offsetY = object.height / 2; // colorStops must be sorted ascending colorStops.sort(function(a, b) { return a.offset - b.offset; }); - + if (object.type === 'path') { + offsetX = 0; + offsetY = 0; + } for (var prop in coords) { if (prop === 'x1' || prop === 'x2') { - coords[prop] += this.offsetX - object.width / 2; + coords[prop] += this.offsetX - offsetX; } else if (prop === 'y1' || prop === 'y2') { - coords[prop] += this.offsetY - object.height / 2; + coords[prop] += this.offsetY - offsetY; } } diff --git a/src/shapes/ellipse.class.js b/src/shapes/ellipse.class.js index 91cdd035951..97b68840f1c 100644 --- a/src/shapes/ellipse.class.js +++ b/src/shapes/ellipse.class.js @@ -116,10 +116,10 @@ * @return {String} svg representation of an instance */ toSVG: function(reviver) { - var markup = this._createBaseSVGMarkup(), x = 0, y = 0; + var markup = this._createBaseSVGMarkup(); markup.push( '