Hi there,
I’m struggling to mask an image with a shape drawn with beginShape(); vertex(); endShape();
Here’s the code (shorted to highlight the key issue):
mskGraphics.image(ink, 100, 100, ink.width / 2, ink.height / 2);
push();
beginShape();
for (let a = 0; a <= TWO_PI; a += TWO_PI / res) {
let noiseX = cos(a) * 15 + 1; //cosine angle x intensity + 1
let noiseY = sin(a) * 15 + 1; //sine angle x intensity + 1
let noiseVal = noise(noiseX, noiseY, t); //lookup value at this xy location in perlin noise field
let attenuatedNoiseVal = map(noiseVal, 0.0, 1.0, 0.5, 1.0); // map noiseVal to amplitude
x = cos(a) * rad * attenuatedNoiseVal;
y = sin(a) * rad * attenuatedNoiseVal;
msk.vertex(x, y);
}
(mskClone = mskGraphics.get()).mask(msk.get());
endShape(CLOSE);
pop();
image(mskClone, 0, 0);
What I want is to a) create a wiggly shape as a mask, and b) use this to mask out a texture.png. What actually happens is that the texture doesn’t appear at all. Weirdly if you comment out the two lines that should show what’s been drawn: