diff --git a/src/mixins/object_geometry.mixin.js b/src/mixins/object_geometry.mixin.js index 71a2e9a5..fc7bb169 100644 --- a/src/mixins/object_geometry.mixin.js +++ b/src/mixins/object_geometry.mixin.js @@ -308,8 +308,8 @@ f = function (p) { return fabric.util.transformPoint(p, vpt); }, - w = this.width, - h = this.height, + w = this.width, currentWidth, + h = this.height, currentHeight, capped = this.strokeLineCap === 'round' || this.strokeLineCap === 'square', vLine = this.type === 'line' && this.width === 0, hLine = this.type === 'line' && this.height === 0, @@ -329,21 +329,21 @@ if (strokeH) { h += h > 0 ? strokeWidth : -strokeWidth; } - this.currentWidth = w * this.scaleX; - this.currentHeight = h * this.scaleY; + currentWidth = w * this.scaleX + 2 * this.padding; + currentHeight = h * this.scaleY + 2 * this.padding; // If width is negative, make postive. Fixes path selection issue - if (this.currentWidth < 0) { - this.currentWidth = Math.abs(this.currentWidth); + if (currentWidth < 0) { + currentWidth = Math.abs(currentWidth); } var _hypotenuse = Math.sqrt( - Math.pow(this.currentWidth / 2, 2) + - Math.pow(this.currentHeight / 2, 2)), + Math.pow(currentWidth / 2, 2) + + Math.pow(currentHeight / 2, 2)), _angle = Math.atan( - isFinite(this.currentHeight / this.currentWidth) - ? this.currentHeight / this.currentWidth + isFinite(currentHeight / currentWidth) + ? currentHeight / currentWidth : 0), // offset added for rotate and scale actions @@ -352,7 +352,7 @@ sinTh = Math.sin(theta), cosTh = Math.cos(theta), coords = this.getCenterPoint(), - wh = new fabric.Point(this.currentWidth, this.currentHeight), + wh = new fabric.Point(currentWidth, currentHeight), _tl = new fabric.Point(coords.x - offsetX, coords.y - offsetY), _tr = new fabric.Point(_tl.x + (wh.x * cosTh), _tl.y + (wh.x * sinTh)), _bl = new fabric.Point(_tl.x - (wh.y * sinTh), _tl.y + (wh.y * cosTh)), @@ -365,21 +365,7 @@ mt = f(_mt), mr = f(new fabric.Point(_tr.x - (wh.y/2 * sinTh), _tr.y + (wh.y/2 * cosTh))), mb = f(new fabric.Point(_bl.x + (wh.x/2 * cosTh), _bl.y + (wh.x/2 * sinTh))), - mtr = f(new fabric.Point(_mt.x, _mt.y)), - - // padding - padX = Math.cos(_angle + theta) * this.padding * Math.sqrt(2), - padY = Math.sin(_angle + theta) * this.padding * Math.sqrt(2); - - tl = tl.add(new fabric.Point(-padX, -padY)); - tr = tr.add(new fabric.Point(padY, -padX)); - br = br.add(new fabric.Point(padX, padY)); - bl = bl.add(new fabric.Point(-padY, padX)); - ml = ml.add(new fabric.Point((-padX - padY) / 2, (-padY + padX) / 2)); - mt = mt.add(new fabric.Point((padY - padX) / 2, -(padY + padX) / 2)); - mr = mr.add(new fabric.Point((padY + padX) / 2, (padY - padX) / 2)); - mb = mb.add(new fabric.Point((padX - padY) / 2, (padX + padY) / 2)); - mtr = mtr.add(new fabric.Point((padY - padX) / 2, -(padY + padX) / 2)); + mtr = f(new fabric.Point(_mt.x, _mt.y)); // debugging