I am working on image cropper using fabric js version 1.7.22. As usually, every cropper display black transparent overlay over the image (where image look like dull), and also display one Rect. (crop Area where image look full with color).
we can create this functionality using fabric js with background image and fabric.Rect
object.
My problem is that when I use GlobalCompositeOperation
with destination-out
property to fabric.Rect
object. It will make hole through canvas.
In simple word :
when I add globalCompositeOperation
to destination-out
, it will make hole through canvas also.
I have made one codepen for demonstration : https://codepen.io/mayurkukadiya0/pen/zYYWOGL?editors=0110
I have found one codepen also for do same but they are add multiple canvas for display image in separate layer and rect and overlay in separate layer Is there any way to do this without add external any canvas or css image behind canvas ? Here is that reference : https://codepen.io/s0nnyv123/pen/eravaN