Please guide me to modify Fabricjs to add custom icon for Rotation.
I get some of the answers but it is not working fine.
Please let me know the code to chan
For fabricjs above 1.6.6 changing function object prototype drawControls, small changes on hasRotation condition, result can be seen this JSFidle
fabric.Object.prototype.drawControls = function (ctx) {
if (!this.hasControls) {
return this;
}
var wh = this._calculateCurrentDimensions(),
width = wh.x,
height = wh.y,
scaleOffset = this.cornerSize,
left = -(width + scaleOffset) / 2,
top = -(height + scaleOffset) / 2,
methodName = this.transparentCorners ? 'stroke' : 'fill';
ctx.save();
ctx.strokeStyle = ctx.fillStyle = this.cornerColor;
if (!this.transparentCorners) {
ctx.strokeStyle = this.cornerStrokeColor;
}
this._setLineDash(ctx, this.cornerDashArray, null);
// top-left
this._drawControl('tl', ctx, methodName,left,top);
// top-right
this._drawControl('tr', ctx, methodName, left + width,top);
// bottom-left
this._drawControl('bl', ctx, methodName,left, top + height);
// bottom-right
this._drawControl('br', ctx, methodName,left + width,top + height);
if (!this.get('lockUniScaling')) {
// middle-top
this._drawControl('mt', ctx, methodName,
left + width / 2,
top);
// middle-bottom
this._drawControl('mb', ctx, methodName,
left + width / 2,
top + height);
// middle-right
this._drawControl('mr', ctx, methodName,
left + width,
top + height / 2);
// middle-left
this._drawControl('ml', ctx, methodName,
left,
top + height / 2);
}
// middle-top-rotate
if (this.hasRotatingPoint) {
var rotate = new Image(), rotateLeft, rotateTop;
rotate.src = 'http://localhost:8000/images/toolbar/close.svg';
rotateLeft = left + width / 2;
rotateTop = top - this.rotatingPointOffset;
ctx.drawImage(rotate, rotateLeft, rotateTop, 10, 15);
}
ctx.restore();
return this;
}