Is it possible to fill color to contour part?

Hello,

I am working on a project to build the sweater model and I have the functionality to add an image to mask the image in the sweater. I’m using contours for this. I want to change the color of only the contoured part, but the problem appears there.

p5.beginShape();
p5.vertex(0, 0);
p5.vertex(p5.width, 0);
p5.vertex(p5.width, p5.height);
p5.vertex(0, p5.height);
p5.beginContour();
p5.fill(255,0,0);
// sweater model here

p5.endContour();
p5.endShape(p5.CLOSE);

The issue is that when I give fill, it gives color to the whole canvas, but I just want to have color in the contour part.

Is it possible to do so?

Hi @nijatmursali and welcome to the Processing community forum :slight_smile:

The beginContour() and endContour() methods make a hole in your shape. It is not possible to give a color to the hole.

There are many ways to accomplish what you want to do. For example, you could draw your sweater design before this code, then draw the “background” on top with a sweater shaped hole like you’re already doing.

1 Like