Skip to content

Commit 0de2773

Browse files
committed
Implement smooth()/noSmooth() methods according to the new method
Signed-off-by: Umair Khan <[email protected]>
1 parent aae0c14 commit 0de2773

File tree

2 files changed

+48
-25
lines changed

2 files changed

+48
-25
lines changed

core/src/processing/core/PApplet.java

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,13 @@ public void onCreate(Bundle savedInstanceState) {
507507
"Error: Unsupported renderer class: %s", rendererName);
508508
throw new RuntimeException(message);
509509
}
510+
511+
//set smooth level
512+
if (smooth == 0) {
513+
g.noSmooth();
514+
} else {
515+
g.smooth(smooth);
516+
}
510517

511518
// g = ((SketchSurfaceView) surfaceView).getGraphics();
512519

@@ -1599,6 +1606,44 @@ public void size(int iwidth, int iheight, String irenderer) {
15991606
}
16001607
}
16011608
}
1609+
1610+
1611+
//. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1612+
1613+
1614+
public void smooth() {
1615+
smooth(1);
1616+
}
1617+
1618+
1619+
public void smooth(int level) {
1620+
if (insideSettings) {
1621+
this.smooth = level;
1622+
1623+
} else if (this.smooth != level) {
1624+
smoothWarning("smooth");
1625+
}
1626+
}
1627+
1628+
1629+
public void noSmooth() {
1630+
if (insideSettings) {
1631+
this.smooth = 0;
1632+
1633+
} else if (this.smooth != 0) {
1634+
smoothWarning("noSmooth");
1635+
}
1636+
}
1637+
1638+
1639+
private void smoothWarning(String method) {
1640+
// When running from the PDE, say setup(), otherwise say settings()
1641+
final String where = external ? "setup" : "settings";
1642+
PGraphics.showWarning("%s() can only be used inside %s()", method, where);
1643+
}
1644+
1645+
1646+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16021647

16031648

16041649
// not finished yet--will swap the renderer at a bad time
@@ -8575,28 +8620,6 @@ public void curve(float x1, float y1, float z1,
85758620
}
85768621

85778622

8578-
/**
8579-
* If true in PImage, use bilinear interpolation for copy()
8580-
* operations. When inherited by PGraphics, also controls shapes.
8581-
*/
8582-
public void smooth() {
8583-
g.smooth();
8584-
}
8585-
8586-
8587-
public void smooth(int level) {
8588-
g.smooth(level);
8589-
}
8590-
8591-
8592-
/**
8593-
* Disable smoothing. See smooth().
8594-
*/
8595-
public void noSmooth() {
8596-
g.noSmooth();
8597-
}
8598-
8599-
86008623
/**
86018624
* The mode can only be set to CORNERS, CORNER, and CENTER.
86028625
* <p/>

core/src/processing/core/PGraphics.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,18 +2647,18 @@ protected void splineForward(int segments, PMatrix3D matrix) {
26472647
* If true in PImage, use bilinear interpolation for copy()
26482648
* operations. When inherited by PGraphics, also controls shapes.
26492649
*/
2650-
public void smooth() {
2650+
public void smooth() { // ignore
26512651
smooth = true;
26522652
}
26532653

2654-
public void smooth(int level) {
2654+
public void smooth(int level) { // ignore
26552655
smooth = true;
26562656
}
26572657

26582658
/**
26592659
* Disable smoothing. See smooth().
26602660
*/
2661-
public void noSmooth() {
2661+
public void noSmooth() { // ignore
26622662
smooth = false;
26632663
}
26642664

0 commit comments

Comments
 (0)