Skip to content

Commit

Permalink
Reuse mt coordinate values in mtr coordinates. Closes fabricjs#592
Browse files Browse the repository at this point in the history
  • Loading branch information
kangax committed May 1, 2013
1 parent eeecde6 commit 17974a5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
18 changes: 12 additions & 6 deletions dist/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -10288,8 +10288,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
if (this.fill.toLive) {
ctx.save();
ctx.translate(
-this.width / 2 + this.fill.offsetX,
-this.height / 2 + this.fill.offsetY);
-this.width / 2 + this.fill.offsetX || 0,
-this.height / 2 + this.fill.offsetY || 0);
}
ctx.fill();
if (this.fill.toLive) {
Expand Down Expand Up @@ -11209,8 +11209,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
y: bl.y + (this.currentWidth/2 * sinTh)
};
var mtr = {
x: tl.x + (this.currentWidth/2 * cosTh),
y: tl.y + (this.currentWidth/2 * sinTh)
x: mt.x,
y: mt.y
};

// debugging
Expand All @@ -11227,8 +11227,14 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
// canvas.contextTop.fillRect(mt.x, mt.y, 3, 3);
// }, 50);

// clockwise
this.oCoords = { tl: tl, tr: tr, br: br, bl: bl, ml: ml, mt: mt, mr: mr, mb: mb, mtr: mtr };
this.oCoords = {
// corners
tl: tl, tr: tr, br: br, bl: bl,
// middle
ml: ml, mt: mt, mr: mr, mb: mb,
// rotating point
mtr: mtr
};

// set coordinates of the draggable boxes in the corners used to scale/rotate the image
this._setCornerCoords();
Expand Down
6 changes: 3 additions & 3 deletions dist/all.min.js

Large diffs are not rendered by default.

Binary file modified dist/all.min.js.gz
Binary file not shown.
14 changes: 10 additions & 4 deletions src/object_geometry.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@
y: bl.y + (this.currentWidth/2 * sinTh)
};
var mtr = {
x: tl.x + (this.currentWidth/2 * cosTh),
y: tl.y + (this.currentWidth/2 * sinTh)
x: mt.x,
y: mt.y
};

// debugging
Expand All @@ -282,8 +282,14 @@
// canvas.contextTop.fillRect(mt.x, mt.y, 3, 3);
// }, 50);

// clockwise
this.oCoords = { tl: tl, tr: tr, br: br, bl: bl, ml: ml, mt: mt, mr: mr, mb: mb, mtr: mtr };
this.oCoords = {
// corners
tl: tl, tr: tr, br: br, bl: bl,
// middle
ml: ml, mt: mt, mr: mr, mb: mb,
// rotating point
mtr: mtr
};

// set coordinates of the draggable boxes in the corners used to scale/rotate the image
this._setCornerCoords();
Expand Down

0 comments on commit 17974a5

Please sign in to comment.