Skip to content

Commit

Permalink
Merge pull request #776 from hx2A/fix643
Browse files Browse the repository at this point in the history
fix #643 - PShape.beginContour() bug
  • Loading branch information
benfry authored Sep 15, 2023
2 parents f1da373 + 4a967e3 commit 97fd524
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/src/processing/core/PShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -1772,12 +1772,32 @@ protected void drawPrimitive(PGraphics g) {
protected void drawGeometry(PGraphics g) {
// get cache object using g.
g.beginShape(kind);

boolean insideContour = false;
int codeIndex = 0;

if (style) {
for (int i = 0; i < vertexCount; i++) {
if (vertexCodes[codeIndex++] == BREAK) {
if (insideContour) {
g.endContour();
}
g.beginContour();
insideContour = true;
}

g.vertex(vertices[i]);
}
} else {
for (int i = 0; i < vertexCount; i++) {
if (vertexCodes[codeIndex++] == BREAK) {
if (insideContour) {
g.endContour();
}
g.beginContour();
insideContour = true;
}

float[] vert = vertices[i];
if (vert.length < 3 || vert[Z] == 0) {
g.vertex(vert[X], vert[Y]);
Expand All @@ -1786,6 +1806,10 @@ protected void drawGeometry(PGraphics g) {
}
}
}

if (insideContour) {
g.endContour();
}
g.endShape(close ? CLOSE : OPEN);
}

Expand Down

0 comments on commit 97fd524

Please sign in to comment.