mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-28 14:58:16 +00:00
fix path exports svgs (#4274)
This commit is contained in:
parent
5f7e61f02f
commit
5bab9b84b2
2 changed files with 10 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
'<ellipse ', this.getSvgId(),
|
||||
'cx="', x, '" cy="', y, '" ',
|
||||
'cx="0" cy="0" ',
|
||||
'rx="', this.rx,
|
||||
'" ry="', this.ry,
|
||||
'" style="', this.getSvgStyles(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue