Detect mixed smooth/noSmooth. Fixes
ADD
runtime/src/jycessing/MixedSmoothError.java
+package jycessing;
+
+public class MixedSmoothError extends PythonSketchError {
+ public MixedSmoothError() {
+ super("smooth() and noSmooth() cannot be used in the same sketch.");
+ }
+
+ public MixedSmoothError(final String message, final String fileName, final int line) {
+ super(message, fileName, line);
+ }
+}

MODIFY
runtime/src/jycessing/PAppletJythonDriver.java
runtime/src/jycessing/PAppletJythonDriver.java
@@ -1015,6 +1015,9 @@ public class PAppletJythonDriver extends PApplet {
}
}
pixelDensity(detectedPixelDensity);
+ if (detectedSmooth && detectedNoSmooth) {
+ throw new MixedSmoothError();
+ }
if (detectedSmooth) {
smooth();
} else if (detectedNoSmooth) {

ADD
testing/resources/test_mixed_smooth_error.py
+# should throw a mixed smooth exception
+
+background(0)
+noStroke()
+smooth()
+ellipse(30, 48, 36, 36)
+noSmooth()
+ellipse(70, 48, 36, 36)
\ No newline at end of file

MODIFY
testing/src/test/jycessing/JycessingTests.java
testing/src/test/jycessing/JycessingTests.java
@@ -15,6 +15,7 @@ import java.nio.file.StandardCopyOption;
import org.junit.Test;
import jycessing.MixedModeError;
+import jycessing.MixedSmoothError;
import jycessing.PAppletJythonDriver;
import jycessing.Printer;
import jycessing.PythonSketchError;
@@ -306,4 +307,15 @@ public class JycessingTests {
public void unittest() throws Exception {
expectOK("unittest");
}
+
+ // https://github.com/jdf/processing.py/issues/251
+ @Test
+ public void detectMixedSmooth() throws Exception {
+ try {
+ run("mixed_smooth_error");
+ fail("Expected mixed smooth error.");
+ } catch (final MixedSmoothError expected) {
+ // noop
+ }
+ }
}

Detect mixed smooth/noSmooth. Fixes #251.