I'm trying to create a generative canvas in p5js which has about 4 grid layout options controlled by a slider. The main canvas is square in ratio and made of squares, rectangles and circles. An image can be upload to the canvas.
Upon upload how can I get the uploaded image to be masked by one of the shapes on the grid? but also have the flexibility to be masked in the 2nd and 3rd grid option by a different shape? Each grid layout offers different spaces in which the image can be masked by a shape. Ideally the image should fit within the shape by width.
Thanks
The Image.mask function is probably the easiest way to do this. However, it permanently alters the image. So if you want to mask the same image multiple time with different shapes you need to make copies.