diff --git a/src/brushes/pencil_brush.class.js b/src/brushes/pencil_brush.class.js index 7dadaec8..4286aabc 100644 --- a/src/brushes/pencil_brush.class.js +++ b/src/brushes/pencil_brush.class.js @@ -165,12 +165,15 @@ * @return {fabric.Path} Path to add on canvas */ createPath: function(pathData) { - var path = new fabric.Path(pathData); - path.fill = null; - path.stroke = this.color; - path.strokeWidth = this.width; - path.strokeLineCap = this.strokeLineCap; - path.strokeLineJoin = this.strokeLineJoin; + var path = new fabric.Path(pathData, { + fill: null, + stroke: this.color, + strokeWidth: this.width, + strokeLineCap: this.strokeLineCap, + strokeLineJoin: this.strokeLineJoin, + originX: 'center', + originY: 'center' + }); if (this.shadow) { this.shadow.affectStroke = true; diff --git a/src/shapes/path.class.js b/src/shapes/path.class.js index 7b28e6ac..6c6ac6e4 100644 --- a/src/shapes/path.class.js +++ b/src/shapes/path.class.js @@ -101,8 +101,10 @@ this.minY = calcDim.top; this.width = calcDim.width; this.height = calcDim.height; - this.top = this.top || this.minY; - this.left = this.left || this.minX; + calcDim.left += this.originX === 'center' ? this.width / 2 : this.originX === 'right' ? this.width : 0; + calcDim.top += this.originY === 'center' ? this.height / 2 : this.originY === 'bottom' ? this.height : 0; + this.top = this.top || calcDim.top; + this.left = this.left || calcDim.left; this.pathOffset = this.pathOffset || { x: this.minX + this.width / 2, y: this.minY + this.height / 2