Skip to content

Commit c755524

Browse files
committed
Fix PShape rects
1 parent 366c865 commit c755524

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

core/src/processing/core/PGraphics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ public PShape createShape(int kind, float... p) {
17891789
return createShapePrimitive(kind, p);
17901790

17911791
} else if (kind == RECT) {
1792-
if (len != 4 && len != 5 && len != 8 && len != 9) {
1792+
if (len != 4 && len != 5 && len != 8) {
17931793
throw new IllegalArgumentException("Wrong number of parameters for createShape(RECT), see the reference");
17941794
}
17951795
return createShapePrimitive(kind, p);

core/src/processing/core/PShape.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,18 +1637,22 @@ protected void drawPrimitive(PGraphics g) {
16371637

16381638
} else if (kind == RECT) {
16391639
if (image != null) {
1640-
g.imageMode(CORNER);
16411640
g.image(image, params[0], params[1], params[2], params[3]);
16421641
} else {
1643-
if(params.length != 5){
1644-
g.rectMode(CORNER);
1645-
}
1646-
else{
1647-
g.rectMode((int) params[4]);
1642+
if (params.length == 4) {
1643+
g.rect(params[0], params[1],
1644+
params[2], params[3]);
1645+
} else if (params.length == 5) {
1646+
g.rect(params[0], params[1],
1647+
params[2], params[3],
1648+
params[4]);
1649+
} else if (params.length == 8) {
1650+
g.rect(params[0], params[1],
1651+
params[2], params[3],
1652+
params[4], params[5],
1653+
params[6], params[7]);
16481654
}
1649-
g.rect(params[0], params[1], params[2], params[3]);
16501655
}
1651-
16521656
} else if (kind == ELLIPSE) {
16531657
g.ellipseMode(CORNER);
16541658
g.ellipse(params[0], params[1], params[2], params[3]);

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3129,11 +3129,15 @@ protected void tessellateRect() {
31293129
b = params[1];
31303130
c = params[2];
31313131
d = params[3];
3132+
rounded = false;
31323133
if (params.length == 5) {
3133-
mode = (int)(params[4]);
3134+
tl = params[4];
3135+
tr = params[4];
3136+
br = params[4];
3137+
bl = params[4];
3138+
rounded = true;
31343139
}
3135-
rounded = false;
3136-
} else if (params.length == 8 || params.length == 9) {
3140+
} else if (params.length == 8) {
31373141
a = params[0];
31383142
b = params[1];
31393143
c = params[2];
@@ -3142,9 +3146,6 @@ protected void tessellateRect() {
31423146
tr = params[5];
31433147
br = params[6];
31443148
bl = params[7];
3145-
if (params.length == 9) {
3146-
mode = (int)(params[8]);
3147-
}
31483149
rounded = true;
31493150
}
31503151

0 commit comments

Comments
 (0)