From 45160dd5388606f7609593b29aac5cfdc8fb8225 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sun, 8 Jan 2012 22:28:56 +0000 Subject: [PATCH] noStroke and noFill in PShape3D now work when called after building the shape. --- .../examples/Retained/Primitive/Primitive.pde | 24 +++++++++++++++++-- .../src/processing/opengl/PShape3D.java | 5 +++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/java/libraries/opengl/examples/Retained/Primitive/Primitive.pde b/java/libraries/opengl/examples/Retained/Primitive/Primitive.pde index 03442c482..4762f3a87 100644 --- a/java/libraries/opengl/examples/Retained/Primitive/Primitive.pde +++ b/java/libraries/opengl/examples/Retained/Primitive/Primitive.pde @@ -1,4 +1,6 @@ PShape circle; +boolean filled = true; +boolean stroked = true; public void setup() { size(400, 400, P3D); @@ -14,10 +16,28 @@ public void draw () { background(0); if (5000 < millis()) { - circle.fill(map(mouseX, 0, width, 255, 0), 0, 0); - circle.stroke(0, 0, map(mouseY, 0, height, 255, 0)); + if (filled) circle.fill(map(mouseX, 0, width, 255, 0), 0, 0); + if (stroked) circle.stroke(0, 0, map(mouseY, 0, height, 255, 0)); } translate(mouseX, mouseY); shape(circle); } + +void keyPressed() { + if (key == 's') { + if (stroked) { + circle.noStroke(); + stroked = false; + } else { + stroked = true; + } + } else if (key == 'f') { + if (filled) { + circle.noFill(); + filled = false; + } else { + filled = true; + } + } +} diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index f0cc5fa9b..517db0f97 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -598,7 +598,8 @@ public class PShape3D extends PShape { public void noFill() { fill = false; - // What to do here? re-tessellate or change alpha to 0? + colorCalc(0, 0); + fillFromCalc(); } public void fill(int rgb) { @@ -670,6 +671,8 @@ public class PShape3D extends PShape { public void noStroke() { stroke = false; + colorCalc(0, 0); + strokeFromCalc(); }