Merge pull request #1812 from asturur/Free-drawing-position

Free drawing position for paths #1780
This commit is contained in:
Juriy Zaytsev 2014-11-05 21:25:58 +01:00
commit 587122112e
2 changed files with 13 additions and 8 deletions

View file

@ -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;

View file

@ -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