Skip to content

Commit 8b0a44f

Browse files
committed
fix QUADRATIC_VERTEX typo in PShape and other cleanups
1 parent 7d41a70 commit 8b0a44f

File tree

2 files changed

+23
-50
lines changed

2 files changed

+23
-50
lines changed

core/src/processing/core/PShape.java

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,13 +1853,13 @@ protected void drawPath(PGraphics g) {
18531853
break;
18541854

18551855
case QUADRATIC_VERTEX:
1856-
g.quadraticVertex(vertices[index+0][X], vertices[index+0][Y],
1856+
g.quadraticVertex(vertices[index][X], vertices[index][Y],
18571857
vertices[index+1][X], vertices[index+1][Y]);
18581858
index += 2;
18591859
break;
18601860

18611861
case BEZIER_VERTEX:
1862-
g.bezierVertex(vertices[index+0][X], vertices[index+0][Y],
1862+
g.bezierVertex(vertices[index][X], vertices[index][Y],
18631863
vertices[index+1][X], vertices[index+1][Y],
18641864
vertices[index+2][X], vertices[index+2][Y]);
18651865
index += 3;
@@ -1888,14 +1888,14 @@ protected void drawPath(PGraphics g) {
18881888
break;
18891889

18901890
case QUADRATIC_VERTEX:
1891-
g.quadraticVertex(vertices[index+0][X], vertices[index+0][Y], vertices[index+0][Z],
1892-
vertices[index+1][X], vertices[index+1][Y], vertices[index+0][Z]);
1891+
g.quadraticVertex(vertices[index][X], vertices[index][Y], vertices[index][Z],
1892+
vertices[index+1][X], vertices[index+1][Y], vertices[index+1][Z]);
18931893
index += 2;
18941894
break;
18951895

18961896

18971897
case BEZIER_VERTEX:
1898-
g.bezierVertex(vertices[index+0][X], vertices[index+0][Y], vertices[index+0][Z],
1898+
g.bezierVertex(vertices[index][X], vertices[index][Y], vertices[index][Z],
18991899
vertices[index+1][X], vertices[index+1][Y], vertices[index+1][Z],
19001900
vertices[index+2][X], vertices[index+2][Y], vertices[index+2][Z]);
19011901
index += 3;
@@ -1957,14 +1957,14 @@ private void loadBase64Image() {
19571957
* @param imagePath The image path containing the base 64 image data.
19581958
* @return Newly loaded PImage.
19591959
*/
1960-
protected static PImage parseBase64Image(String imagePath) {
1960+
static protected PImage parseBase64Image(String imagePath) {
19611961
String[] parts = imagePath.split(";base64,");
19621962
String extension = parts[0].substring(11);
19631963
String encodedData = parts[1];
19641964

19651965
byte[] decodedBytes = Base64.getDecoder().decode(encodedData);
19661966

1967-
if(decodedBytes == null){
1967+
if (decodedBytes == null) {
19681968
System.err.println("Decode Error on image: " + imagePath.substring(0, 20));
19691969
return null;
19701970
}
@@ -1976,23 +1976,21 @@ protected static PImage parseBase64Image(String imagePath) {
19761976
int space = buffImage.getColorModel().getColorSpace().getType();
19771977
if (space == ColorSpace.TYPE_CMYK) {
19781978
System.err.println("Could not load CMYK color space on image: " + imagePath.substring(0, 20));
1979-
return null;
1979+
return null;
19801980
}
19811981
}
19821982

1983-
// if it's a .gif image, test to see if it has transparency
1984-
boolean requiresCheckAlpha = extension.equals("gif") || extension.equals("png") ||
1985-
extension.equals("unknown");
1986-
19871983
PImage loadedImage = new PImageAWT(awtImage);
19881984

1989-
if (requiresCheckAlpha) {
1990-
loadedImage.checkAlpha();
1985+
// test whether the image has alpha (or we can draw it more quickly in RGB)
1986+
if (extension.equals("gif") || extension.equals("png") ||
1987+
extension.equals("unknown")) {
1988+
loadedImage.checkAlpha();
19911989
}
19921990

1993-
if (loadedImage.width == -1) {
1994-
// error...
1995-
}
1991+
// if (loadedImage.width == -1) {
1992+
// // error...
1993+
// }
19961994

19971995
return loadedImage;
19981996
}
@@ -2534,7 +2532,6 @@ public void setFill(boolean fill) {
25342532
*
25352533
*
25362534
* @webref
2537-
* @param fill
25382535
* @webBrief Set the fill value
25392536
*/
25402537
public void setFill(int fill) {
@@ -2576,7 +2573,7 @@ public void setFill(int index, int fill) {
25762573
vertices[index][PGraphics.A] = ((fill >> 24) & 0xFF) / 255.0f;
25772574
vertices[index][PGraphics.R] = ((fill >> 16) & 0xFF) / 255.0f;
25782575
vertices[index][PGraphics.G] = ((fill >> 8) & 0xFF) / 255.0f;
2579-
vertices[index][PGraphics.B] = ((fill >> 0) & 0xFF) / 255.0f;
2576+
vertices[index][PGraphics.B] = (fill & 0xFF) / 255.0f;
25802577
}
25812578
}
25822579

@@ -2643,7 +2640,7 @@ public void setTint(int index, int tint) {
26432640
vertices[index][PGraphics.A] = ((tint >> 24) & 0xFF) / 255.0f;
26442641
vertices[index][PGraphics.R] = ((tint >> 16) & 0xFF) / 255.0f;
26452642
vertices[index][PGraphics.G] = ((tint >> 8) & 0xFF) / 255.0f;
2646-
vertices[index][PGraphics.B] = ((tint >> 0) & 0xFF) / 255.0f;
2643+
vertices[index][PGraphics.B] = (tint & 0xFF) / 255.0f;
26472644
}
26482645
}
26492646

@@ -2688,7 +2685,6 @@ public void setStroke(boolean stroke) {
26882685
*
26892686
*
26902687
* @webref
2691-
* @param stroke
26922688
* @webBrief Set the stroke value
26932689
*/
26942690
public void setStroke(int stroke) {
@@ -2729,7 +2725,7 @@ public void setStroke(int index, int stroke) {
27292725
vertices[index][PGraphics.SA] = ((stroke >> 24) & 0xFF) / 255.0f;
27302726
vertices[index][PGraphics.SR] = ((stroke >> 16) & 0xFF) / 255.0f;
27312727
vertices[index][PGraphics.SG] = ((stroke >> 8) & 0xFF) / 255.0f;
2732-
vertices[index][PGraphics.SB] = ((stroke >> 0) & 0xFF) / 255.0f;
2728+
vertices[index][PGraphics.SB] = (stroke & 0xFF) / 255.0f;
27332729
}
27342730

27352731

@@ -2845,7 +2841,7 @@ public void setAmbient(int index, int ambient) {
28452841

28462842
vertices[index][PGraphics.AR] = ((ambient >> 16) & 0xFF) / 255.0f;
28472843
vertices[index][PGraphics.AG] = ((ambient >> 8) & 0xFF) / 255.0f;
2848-
vertices[index][PGraphics.AB] = ((ambient >> 0) & 0xFF) / 255.0f;
2844+
vertices[index][PGraphics.AB] = (ambient & 0xFF) / 255.0f;
28492845
}
28502846

28512847

@@ -2893,7 +2889,7 @@ public void setSpecular(int index, int specular) {
28932889

28942890
vertices[index][PGraphics.SPR] = ((specular >> 16) & 0xFF) / 255.0f;
28952891
vertices[index][PGraphics.SPG] = ((specular >> 8) & 0xFF) / 255.0f;
2896-
vertices[index][PGraphics.SPB] = ((specular >> 0) & 0xFF) / 255.0f;
2892+
vertices[index][PGraphics.SPB] = (specular & 0xFF) / 255.0f;
28972893
}
28982894

28992895

@@ -2942,7 +2938,7 @@ public void setEmissive(int index, int emissive) {
29422938

29432939
vertices[index][PGraphics.ER] = ((emissive >> 16) & 0xFF) / 255.0f;
29442940
vertices[index][PGraphics.EG] = ((emissive >> 8) & 0xFF) / 255.0f;
2945-
vertices[index][PGraphics.EB] = ((emissive >> 0) & 0xFF) / 255.0f;
2941+
vertices[index][PGraphics.EB] = (emissive & 0xFF) / 255.0f;
29462942
}
29472943

29482944

@@ -3277,7 +3273,7 @@ public void rotate(float angle, float v0, float v1, float v2) {
32773273
* @webref pshape:method
32783274
* @usage web_application
32793275
* @webBrief Increases and decreases the size of a shape
3280-
* @param s percentate to scale the object
3276+
* @param s percentage to scale the object
32813277
* @see PShape#rotate(float)
32823278
* @see PShape#translate(float, float)
32833279
* @see PShape#resetMatrix()
@@ -3393,30 +3389,6 @@ protected void checkMatrix(int dimensions) {
33933389
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33943390

33953391

3396-
/**
3397-
* Center the shape based on its bounding box. Can't assume
3398-
* that the bounding box is 0, 0, width, height. Common case will be
3399-
* opening a letter size document in Illustrator, and drawing something
3400-
* in the middle, then reading it in as an svg file.
3401-
* This will also need to flip the y axis (scale(1, -1)) in cases
3402-
* like Adobe Illustrator where the coordinates start at the bottom.
3403-
*/
3404-
// public void center() {
3405-
// }
3406-
3407-
3408-
/**
3409-
* Set the pivot point for all transformations.
3410-
*/
3411-
// public void pivot(float x, float y) {
3412-
// px = x;
3413-
// py = y;
3414-
// }
3415-
3416-
3417-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3418-
3419-
34203392
public void colorMode(int mode) {
34213393
colorMode(mode, colorModeX, colorModeY, colorModeZ, colorModeA);
34223394
}

core/todo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
1277 (4.0b2)
2+
X fix apparent problem in PShape with QUADRATIC_VERTEX (wrong vertex index)
23

34

45
contribs

0 commit comments

Comments
 (0)