diff --git a/src/shapes/line.class.js b/src/shapes/line.class.js index c1289567ea4..1169e930855 100644 --- a/src/shapes/line.class.js +++ b/src/shapes/line.class.js @@ -167,10 +167,11 @@ // Line coords are distances from left-top of canvas to origin of line. // To render line in a path-group, we need to translate them to // distances from center of path-group to center of line. - var cp = this.getCenterPoint(); + var cp = this.getCenterPoint(), + offset = this.strokeWidth / 2; ctx.translate( - cp.x - this.strokeWidth / 2, - cp.y - this.strokeWidth / 2 + cp.x - (this.strokeLineCap === 'butt' && this.height === 0 ? 0 : offset), + cp.y - (this.strokeLineCap === 'butt' && this.width === 0 ? 0 : offset) ); } @@ -222,10 +223,10 @@ _getNonTransformedDimensions: function() { var dim = this.callSuper('_getNonTransformedDimensions'); if (this.strokeLineCap === 'butt') { - if (dim.x === 0) { + if (this.width === 0) { dim.y -= this.strokeWidth; } - if (dim.y === 0) { + if (this.height === 0) { dim.x -= this.strokeWidth; } }