From 2cfe384d570f4c997ba2b0f75d463c7a4395792a Mon Sep 17 00:00:00 2001 From: Cat Sync Date: Sun, 5 Aug 2012 16:58:27 -0400 Subject: [PATCH] Fix for polygon bounding box being offset (issue #147) --- src/polygon.class.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/polygon.class.js b/src/polygon.class.js index 8b0c0233..abef98ee 100644 --- a/src/polygon.class.js +++ b/src/polygon.class.js @@ -98,11 +98,13 @@ */ _render: function(ctx) { var point; + var offsetX = this.minX + this.width / 2, + offsetY = this.minY + this.height / 2; ctx.beginPath(); - ctx.moveTo(this.points[0].x, this.points[0].y); + ctx.moveTo(this.points[0].x - offsetX, this.points[0].y - offsetY); for (var i = 0, len = this.points.length; i < len; i++) { point = this.points[i]; - ctx.lineTo(point.x, point.y); + ctx.lineTo(point.x - offsetX, point.y - offsetY); } if (this.fill) { ctx.fill();