I have a problem that I'd like to add round mask on top of the editable fabric.js HTML5 canvas. Similar problem is described in this article:
Creating an Image Mask with HTML 5 Canvas
My problem is that when I add this layer on top of the fabric.js canvas then my canvas is not editable any more inside this transparent circle. This means that the top element (the mask) captures the click/drag event, but I'd like to move the items under this mask element. Looking for ideas, how to work around this problem.
You can utilize built-in support for masks in fabric.
Here's an example of creating a circular mask at 100/100 with the radius of 200:
var canvas = new fabric.Canvas('...');
// ...
canvas.clipTo = function (ctx) {
ctx.arc(100, 100, 200, 0, Math.PI*2, true);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With