My contour doesn't work

I tried to create a plane with a hole in the middle. It works with the example on the documentation, but I don’t succeed to make it work with my values. Is there any constraint on values?
Here is my code:

float x = 980;
float y = 280;
void setup() {
  size(900, 900, P3D);
  
}

void draw() {
  
 translate(200,200);  
 createShape();
 beginShape();
    textureMode(NORMAL);
    shininess(200);
    emissive(0, 0, 0);
    normal(0, 0, 1);
    vertex(-x/2, -y/2, 0, 0); 
    vertex(x/2, -y/2, 1, 0); 
    vertex(x/2, y/2, 1, 1); 
    vertex(-x/2, y/2, 0, 1); 
     
    beginContour();
      vertex(-x/2+115, -y/2+35, 0, 0); 
      vertex(x/2-115, -y/2+35, 1, 0); 
      vertex(x/2-115, y/2-105, 1, 1); 
      vertex(-x/2+115, y/2-105, 0, 1); 
     endContour();
     
   endShape(CLOSE);
}

Can you help me please?

Hello @TF-SHOCK76,

Read the reference carefully about the winding direction:
https://processing.org/reference/beginContour_.html

Once I corrected your code (winding of vertices) it worked:

Some code to help you see the co-ordinates:

void setup()
  {
  size(500, 500);  
  }

void draw() 
  {
  background(255);
  strokeWeight(5);
  point(mouseX, mouseY);
  fill(0);
  text(str(mouseX) + ", " + str(mouseY), mouseX +10, mouseY);
  println(mouseX, mouseY);
  }

References:

:)

3 Likes

Hi glv,
Thank for your reply! It works now ^^
Bye,

TF.

1 Like