Hello,
Here is an example using the existing circle()
shape:
PImage img1, img2;
PGraphics pg;
void setup()
{
size(300, 300);
//img1 = loadImage("https://processing.org/img/processing-web.png");
img1 = loadImage("https://raw.githubusercontent.com/processing/processing-website/main/content/examples/Basics/Image/LoadDisplayImage/data/moonwalk.jpg");
img2 = createImage(100, 100, RGB);
img2 = img1.get(360, 100, 100, 100);
pg = createGraphics(100, 100);
pg.beginDraw();
//pg.background(0);
pg.noStroke();
pg.fill(0, 0, 255); // Look this up in the references
pg.circle(50, 50, 100);
pg.endDraw();
// The "pg image" is masking the "img2 image"
img2.mask(pg); //Look this up in the references
background(255, 128, 0, 255);
image(img2, 100, 100);
noLoop();
}
Look up all the tutorials and references related to the example:
You will have to use createShape()
to create a shape with your vertices to replace the circle()
shape in the example with your shape.
This may also be of interest:
:)