mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-13 16:23:11 +00:00
Merge pull request #1812 from asturur/Free-drawing-position
Free drawing position for paths #1780
This commit is contained in:
commit
587122112e
2 changed files with 13 additions and 8 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue