How can i clip image by another image? I need behavoior like in fabric.js clipPath - one image clip another. Main image will be aditable - draggable and scalable, clip image will be static. Main Image can contain video
I try [https://jsfiddle.net/mgdah8wc/23/] but after adding group with clipped image all shapes under it wi bell clipped to. Make like [https://jsfiddle.net/xLL3veu6/] i cant becose i have several images with clipping
If the aim is to use (a) the giraffe image as a mask to make a path to be filled with (b) the grey image then have them both appear above (c) the orange rect then you need to compose the a + b interaction to a separate canvas and grab the image off that into the canvas. See snippet below.
Konva is a wrapper for the HTML5 canvas and as such it is subject to the same compositing rules as the canvas. It is likely that fabric uses this intermediate canvas compositing approach too under the covers.
EDIT: Someone mentioned that using another stage was not the optimum solution. They proposed using a group. However the issue here is that the compositing setting covers the entire canvas - and a group is drawn into the layer, which in Konva is itself a canvas. What I mean by this is that the destination-in operates over the entire layer that the group is located on, so that wipes out image of the the prior shapes that has been built up on the layer. It is possible to use another layer in the same stage because in Konva each layer is a canvas.
First demo: using a hidden canvas.
Second demo: using additional layer on the original stage.