Perhaps this could help (as found in this question ).
First you need to add the background canvas object to which you want to make a “hole”. Then you create a new object (cutter) and set the property globalCompositeOperation = 'destination-out', and then add it to the canvas.
Similar:
var h = new fabric.Rect({width: canvas.width, height: canvas.height, fill: 'rgba(0,0,0,0.5)'})
var z = new fabric.Circle({radius: 100, top:100, left: 100, globalCompositeOperation: 'destination-out'})
canvas.add(h).add(z)
Thus, you first add the global object, and then add the object as a “cutter”. I think that it will act as a cutter for everything, so if you have other objects "behind", they will also be cropped (did not test it).
Hope this helps!
source
share