mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-09 14:24:44 +00:00
Update polygon.class.js
This commit is contained in:
parent
345c403a8e
commit
1c9932f97f
1 changed files with 10 additions and 6 deletions
|
|
@ -66,8 +66,10 @@
|
|||
if (!('left' in options)) {
|
||||
this.left = this.minX;
|
||||
}
|
||||
this.offsetX = this.minX + this.width / 2;
|
||||
this.offsetY = this.minY + this.height / 2;
|
||||
this.pathOffset = {
|
||||
x: this.minX + this.width / 2,
|
||||
y: this.minY + this.height / 2
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -106,18 +108,20 @@
|
|||
* @return {String} svg representation of an instance
|
||||
*/
|
||||
toSVG: function(reviver) {
|
||||
var points = [],
|
||||
var points = [], addTransform,
|
||||
markup = this._createBaseSVGMarkup();
|
||||
|
||||
for (var i = 0, len = this.points.length; i < len; i++) {
|
||||
points.push(toFixed(this.points[i].x, 2), ',', toFixed(this.points[i].y, 2), ' ');
|
||||
}
|
||||
|
||||
if (!(this.group && this.group.type === 'path-group')) {
|
||||
addTransform = ' translate(' + (-this.pathOffset.x) + ', ' + (-this.pathOffset.y) + ') ';
|
||||
}
|
||||
markup.push(
|
||||
'<', this.type, ' ',
|
||||
'points="', points.join(''),
|
||||
'" style="', this.getSvgStyles(),
|
||||
'" transform="', this.getSvgTransform(),
|
||||
'" transform="', this.getSvgTransform(), addTransform,
|
||||
' ', this.getSvgTransformMatrix(),
|
||||
'"/>\n'
|
||||
);
|
||||
|
|
@ -154,7 +158,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
noTransform || ctx.translate(-this.offsetX, -this.offsetY);
|
||||
noTransform || ctx.translate(-this.pathOffset.x, -this.pathOffset.y);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.points[0].x, this.points[0].y);
|
||||
for (var i = 0; i < len; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue