Skip to content

Commit 366c865

Browse files
committed
Fix PShape arcs
1 parent ba09591 commit 366c865

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

core/src/processing/core/PGraphics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ public PShape createShape(int kind, float... p) {
18021802

18031803
} else if (kind == ARC) {
18041804
if (len != 6 && len != 7) {
1805-
throw new IllegalArgumentException("Use createShape(ARC, x, y, w, h, start, stop)");
1805+
throw new IllegalArgumentException("Use createShape(ARC, x, y, w, h, start, stop) or createShape(ARC, x, y, w, h, start, stop, arcMode)");
18061806
}
18071807
return createShapePrimitive(kind, p);
18081808

core/src/processing/core/PShape.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,9 +1654,16 @@ protected void drawPrimitive(PGraphics g) {
16541654
g.ellipse(params[0], params[1], params[2], params[3]);
16551655

16561656
} else if (kind == ARC) {
1657-
g.ellipseMode(CORNER);
1658-
g.arc(params[0], params[1], params[2], params[3], params[4], params[5]);
1659-
1657+
if (params.length == 6) {
1658+
g.arc(params[0], params[1],
1659+
params[2], params[3],
1660+
params[4], params[5]);
1661+
} else if (params.length == 7) {
1662+
g.arc(params[0], params[1],
1663+
params[2], params[3],
1664+
params[4], params[5],
1665+
(int) params[6]);
1666+
}
16601667
} else if (kind == BOX) {
16611668
if (params.length == 1) {
16621669
g.box(params[0]);

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,6 +3257,7 @@ protected void tessellateArc() {
32573257
float a = 0, b = 0, c = 0, d = 0;
32583258
float start = 0, stop = 0;
32593259
int mode = ellipseMode;
3260+
int arcMode = 0;
32603261

32613262
if (6 <= params.length) {
32623263
a = params[0];
@@ -3266,7 +3267,7 @@ protected void tessellateArc() {
32663267
start = params[4];
32673268
stop = params[5];
32683269
if (params.length == 7) {
3269-
mode = (int)(params[6]);
3270+
arcMode = (int)(params[6]);
32703271
}
32713272
}
32723273

@@ -3301,13 +3302,13 @@ protected void tessellateArc() {
33013302
}
33023303

33033304
if (stop - start > TWO_PI) {
3304-
start = 0;
3305-
stop = TWO_PI;
3305+
// don't change start, it is visible in PIE mode
3306+
stop = start + TWO_PI;
33063307
}
33073308
inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
33083309
ambientColor, specularColor, emissiveColor, shininess);
33093310
inGeo.setNormal(normalX, normalY, normalZ);
3310-
inGeo.addArc(x, y, w, h, start, stop, fill, stroke, mode);
3311+
inGeo.addArc(x, y, w, h, start, stop, fill, stroke, arcMode);
33113312
tessellator.tessellateTriangleFan();
33123313
}
33133314
}

0 commit comments

Comments
 (0)