I have a full-screen background canvas, I want to draw elements on top of that canvas that act as a mask. So the canvas should only be visible through the overlaying elements.
Here's a picture on what I'm trying to achieve:
In the left picture is what I currently have, where the gradient background acts as the canvas element. The picture on the right is what I attempt to achieve, where the 2 divs (mask, mask 2). In addition, the 2 elements (mask, mask 2) should be draggable, so if the element moves, the background will still match up with what the canvas is showing.
I tried to do this using mask, a clip-path, but I can't seem to get it working. What's the best approach to get the desired result?
The easiest is probably to use CSS to mask your output
<canvas>
.You can use the
mask
property with onelinear-gradient
asmask-image
per element to do so.