Skip to content

Commit 97fd524

Browse files
authored
Merge pull request #776 from hx2A/fix643
fix #643 - PShape.beginContour() bug
2 parents f1da373 + 4a967e3 commit 97fd524

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

core/src/processing/core/PShape.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,12 +1772,32 @@ protected void drawPrimitive(PGraphics g) {
17721772
protected void drawGeometry(PGraphics g) {
17731773
// get cache object using g.
17741774
g.beginShape(kind);
1775+
1776+
boolean insideContour = false;
1777+
int codeIndex = 0;
1778+
17751779
if (style) {
17761780
for (int i = 0; i < vertexCount; i++) {
1781+
if (vertexCodes[codeIndex++] == BREAK) {
1782+
if (insideContour) {
1783+
g.endContour();
1784+
}
1785+
g.beginContour();
1786+
insideContour = true;
1787+
}
1788+
17771789
g.vertex(vertices[i]);
17781790
}
17791791
} else {
17801792
for (int i = 0; i < vertexCount; i++) {
1793+
if (vertexCodes[codeIndex++] == BREAK) {
1794+
if (insideContour) {
1795+
g.endContour();
1796+
}
1797+
g.beginContour();
1798+
insideContour = true;
1799+
}
1800+
17811801
float[] vert = vertices[i];
17821802
if (vert.length < 3 || vert[Z] == 0) {
17831803
g.vertex(vert[X], vert[Y]);
@@ -1786,6 +1806,10 @@ protected void drawGeometry(PGraphics g) {
17861806
}
17871807
}
17881808
}
1809+
1810+
if (insideContour) {
1811+
g.endContour();
1812+
}
17891813
g.endShape(close ? CLOSE : OPEN);
17901814
}
17911815

0 commit comments

Comments
 (0)