# Issue with PShape with a cut off area and a changing vertex

**URL:** <https://discourse.processing.org/t/issue-with-pshape-with-a-cut-off-area-and-a-changing-vertex/35859>\
**Category:** Processing\
**Created:** [March 20, 2022, 12:06pm UTC](https://discourse.processing.org/t/issue-with-pshape-with-a-cut-off-area-and-a-changing-vertex/35859 "2022-03-20T12:06:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BleiEnte](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@BleiEnte](https://discourse.processing.org/u/BleiEnte)\
**Post date:** [March 20, 2022, 12:06pm UTC](https://discourse.processing.org/t/issue-with-pshape-with-a-cut-off-area-and-a-changing-vertex/35859/1 "2022-03-20T12:06:20Z")

</div>

Hey, I’d like to wirte a simple sketch where some vertices of a shape with an cut off are changed. Unfortunately, it doesn’t work as expected.  
If I choose the default renderer, the shape is not closed as intended (see this [bug](https://github.com/processing/processing/issues/4978) )  
If I choose P2D I get some strange artefacts while changing the vertex. If the new coordinates of the vertex are greater than the original values (here 50), the shape is not anymore shown correctly.

Is the P2D behaviour also some kind of a bug?

```auto
PShape s;

void setup() {
  size(200, 200, P2D); // issue with alteres vertexes
  //size(200, 200); // default rendere works with setVertex, but doesn't close the shape +
                    // ignores beginContour(), endContour()

  // Make a shape
  s = createShape();
  s.beginShape();

  // Exterior part of shape
  s.vertex(-50, -50);
  s.vertex(50, -50);
  s.vertex(50, 50);
  s.vertex(-50, 50);

  // Interior part of shape
  s.beginContour();
  s.vertex(-20, -20);
  s.vertex(-20, 20);
  s.vertex(20, 20);
  s.vertex(20, -20);
  s.endContour();

  // Finish off shape
  s.endShape(CLOSE);
}

void draw() {
  background(204);
  float x = map(mouseX, 0, width, 30, 70);
  float y = map(mouseY, 0, height, 30, 70);
  fill(255, 0, 0);
  text("x: " + round(x) + ", y: " + round(y), 10, 12);

  fill(255);
  s.setVertex(2, x, y );
  translate(width/2, height/2);
  shape(s);
}

```
