How to create a reverse fill? Possible?

Hello!

I am trying to figure out how to create a reverse fill of this shape that I have drawn. The purpose of the reverse fill will be to block out some other shapes that I’m drawing outside the borders of this original shape.

Here is the shape:


void setup() {
  size(1080,1080);
  background(0);
}

void draw() {
  pushMatrix();
  translate(width/2,height/2);
  beginShape();
  noFill();
  stroke(255);
  for (float a = 0; a < TWO_PI; a+=0.01) {
   float r = 400;
   float x = r * pow(cos(a),3);
   float y = r * sin(a);
   vertex(x*0.5,y);
  }
  endShape();
  popMatrix();
}

Attached is an illustration of the reverse fill that I created using Photoshop, but I’m wondering if I can create the black section programmatically to give me the ability to morph (grow and shrink) the black, reverse fill section along with the original shape in real-time. Let me know if this makes sense or if there are any questions!

Thanks for any help in advance!

Ended up figuring this one out. For anyone interested, the beginContour() and endContour() functions allow you to do this!

https://processing.org/reference/PShape_beginContour_.html

1 Like