Skip to content

Commit

Permalink
Adding Close icon on left, top
Browse files Browse the repository at this point in the history
  • Loading branch information
lukluk committed Jun 14, 2012
1 parent 72a63fe commit ff740b5
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions src/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@
* @return {fabric.Object} thisArg
* @chainable
*/
drawCorners: function(ctx) {
drawCorners: function(ctx) {
if (!this.hasControls) return;

var size = this.cornersize,
Expand All @@ -660,6 +660,10 @@
_top,
sizeX = size / this.scaleX,
sizeY = size / this.scaleY,
sizeXr = (size*1.7) / this.scaleX,
sizeYr = (size*1.7) / this.scaleY,
sizeXc = (size*1.3) / this.scaleX,
sizeYc = (size*1.3) / this.scaleY,
scaleOffsetY = (padding + size2) / this.scaleY,
scaleOffsetX = (padding + size2) / this.scaleX,
scaleOffsetSizeX = (padding + size2 - size) / this.scaleX,
Expand All @@ -672,12 +676,14 @@
ctx.fillStyle = this.cornerColor;

// top-left
_left = left - scaleOffsetX;
_top = top - scaleOffsetY;
ctx.fillRect(_left, _top, sizeX, sizeY);

_left = left - scaleOffsetX ;
_top = top - scaleOffsetY ;
//ctx.fillRect(_left, _top, sizeX, sizeY);
var thumbImg = document.createElement('img');
thumbImg.src = 'close.png';
ctx.drawImage(thumbImg, (_left), (_top), sizeX, sizeY);
// top-right
_left = left + this.width - scaleOffsetX;
_left = left + this.width + scaleOffsetSizeX;
_top = top - scaleOffsetY;
ctx.fillRect(_left, _top, sizeX, sizeY);

Expand All @@ -692,40 +698,25 @@
ctx.fillRect(_left, _top, sizeX, sizeY);

// middle-top
_left = left + this.width/2 - scaleOffsetX;
_left = left + this.width/2 - scaleOffsetSizeX;
_top = top - scaleOffsetY;
ctx.fillRect(_left, _top, sizeX, sizeY);

// middle-bottom
_left = left + this.width/2 - scaleOffsetX;
_left = left + this.width/2 - scaleOffsetSizeX;
_top = top + height + scaleOffsetSizeY;
ctx.fillRect(_left, _top, sizeX, sizeY);

// middle-right
_left = left + this.width + scaleOffsetSizeX;
_top = top + height/2 - scaleOffsetY;
_top = top + height/2 - scaleOffsetSizeY;
ctx.fillRect(_left, _top, sizeX, sizeY);

// middle-left
_left = left - scaleOffsetX;
_top = top + height/2 - scaleOffsetY;
_top = top + height/2 - scaleOffsetSizeY;
ctx.fillRect(_left, _top, sizeX, sizeY);

// middle-top-rotate
if (this.hasRotatingPoint) {
// _left = left + this.width/2;
// _top = top - (45 / this.scaleY) + scaleOffsetY;

// ctx.save();
// ctx.beginPath();
// ctx.arc(_left, _top, sizeX / 2, 0, Math.PI * 2, false);
// ctx.fill();
// ctx.restore();
_left = left + this.width/2 - scaleOffsetX;
_top = top - (45 / this.scaleY);
ctx.fillRect(_left, _top, sizeX, sizeY);
}

ctx.restore();

return this;
Expand Down

0 comments on commit ff740b5

Please sign in to comment.