Assuming this will only be for rectangles, the best way would probably be to attach 4 lines too much that you update the positions based on these rectangles x, y, width and height. Then you can set the stroked width of these lines separately.
Another way would be to simply resize the control. Take a look at this JSFiddle .
var canvas = new fabric.Canvas('c', { selection: false }); var circle, isDown, origX, origY; canvas.on('mouse:down', function(o){ isDown = true; var pointer = canvas.getPointer(oe); origX = pointer.x; origY = pointer.y; circle = new fabric.Circle({ left: pointer.x, top: pointer.y, radius: 1, strokeWidth: 5, stroke: 'red', selectable: false, originX: 'center', originY: 'center' }); canvas.add(circle); }); canvas.on('mouse:move', function(o){ if (!isDown) return; var pointer = canvas.getPointer(oe); circle.set({ radius: Math.abs(origX - pointer.x) }); canvas.renderAll(); }); canvas.on('mouse:up', function(o){ isDown = false; });
source share