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
463ecc5e22
commit
345c403a8e
1 changed files with 6 additions and 23 deletions
|
|
@ -66,6 +66,8 @@
|
|||
if (!('left' in options)) {
|
||||
this.left = this.minX;
|
||||
}
|
||||
this.offsetX = this.minX + this.width / 2;
|
||||
this.offsetY = this.minY + this.height / 2;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -86,18 +88,6 @@
|
|||
this.minY = minY || 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_applyPointOffset: function() {
|
||||
// change points to offset polygon into a bounding box
|
||||
// executed one time
|
||||
this.points.forEach(function(p) {
|
||||
p.x -= (this.minX + this.width / 2);
|
||||
p.y -= (this.minY + this.height / 2);
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns object representation of an instance
|
||||
* @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
|
||||
|
|
@ -140,8 +130,8 @@
|
|||
* @private
|
||||
* @param {CanvasRenderingContext2D} ctx Context to render on
|
||||
*/
|
||||
_render: function(ctx) {
|
||||
if (!this.commonRender(ctx)) {
|
||||
_render: function(ctx, noTransform) {
|
||||
if (!this.commonRender(ctx, noTransform)) {
|
||||
return;
|
||||
}
|
||||
this._renderFill(ctx);
|
||||
|
|
@ -155,7 +145,7 @@
|
|||
* @private
|
||||
* @param {CanvasRenderingContext2D} ctx Context to render on
|
||||
*/
|
||||
commonRender: function(ctx) {
|
||||
commonRender: function(ctx, noTransform) {
|
||||
var point, len = this.points.length;
|
||||
|
||||
if (!len || isNaN(this.points[len - 1].y)) {
|
||||
|
|
@ -164,15 +154,8 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
noTransform || ctx.translate(-this.offsetX, -this.offsetY);
|
||||
ctx.beginPath();
|
||||
|
||||
if (this._applyPointOffset) {
|
||||
if (!(this.group && this.group.type === 'path-group')) {
|
||||
this._applyPointOffset();
|
||||
}
|
||||
this._applyPointOffset = null;
|
||||
}
|
||||
|
||||
ctx.moveTo(this.points[0].x, this.points[0].y);
|
||||
for (var i = 0; i < len; i++) {
|
||||
point = this.points[i];
|
||||
|
|
|
|||
Loading…
Reference in a new issue