-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
beginContour() and endContour doesnt work on shape #643
Comments
That's a typo in the documentation. It should be |
@benfry I don't think the issue is resolved, or at least it is not clear how your answer solves the problem. I tried the provided example in the Foundation and it didn't work. The problem was observed in this post: https://forum.processing.org/two/discussion/comment/97902#Comment_97902 Below is an example from that post. kfrajer
|
Using I can't tell from your code what you're expecting it to do. Also, those |
The surprising thing here is that, given two otherwise identical code blocks with identical vertices in this form:
...the same code produces two different results:
The left and center images show this surprising result. The "added vertices" example on the right was kfrajer's fix attempt. Test code:
|
The middle image is the intended result. Is that the confusion here? Again, never make the vertices come back to meet themselves. That'll cause problems. |
The first and middle image are different, but produced by identical
instruction sequences. Is that intended?
The right image is a distraction. Ignore kfrajer's adding vertices, and just focus on the first two examples with identical vertex lists and identical shape and contour calls, but different image outputs.
…On Tue, May 16, 2017 at 12:50 Ben Fry ***@***.***> wrote:
The middle image is the intended result. Is that the confusion here?
Again, never make the vertices come back to meet themselves. That'll cause
problems.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#643>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAwvaoce1oChkvR_8R6M1Lwt8RKqn24Uks5r6f4FgaJpZM4Mmreh>
.
|
Here is a second example of what I believe may be the same issue: Two identical PShape sequences, except that one contains "beginContour / endContour" commands, and one does not. One should contain a contour -- but instead both render the same end shape.
|
Now let's do it again, but take those commands out of PShape methods and use the draw functions instead. Again, two identical sequences of vertices, with the only difference being that one uses "beginContour / endContour", and one does not.
Here, we see two different shapes. That is expected -- one contains a contour, one does not. So within draw, However, as we saw above, within PShape, |
Sorry, misspoke—the correct version is the one marked “contour shape” So, the documentation error is that it's also showing the wrong image, perpetuating the buggy behavior. Ah, what a mess. Now, for someone to fix it… |
@jeremydouglass Can you note this put in /processing/processing-docs/ so the documentation error is recorded? |
@REAS @jeremydouglass I believe benfry already posted this typo in docs: processing/processing-docs#551 and is assigned to your name. kfrajer |
Yes, my mistake. Thank you. |
I walked through this whole thread and I've come back to the conclusion that there's an error. Please check this example, I think the code is equivalent for both:
|
That's right. The two lines Specifically, the contour is working correctly in the left example. If you remove the two Contour code lines, then the correct hollow box shape changes to a simple closed path. The contour is not working in the right example. If you remove the two contour code lines, nothing changes. That's because the lines aren't doing anything in the first place -- although they should be.
|
P2D and P3D also render correctly, In PGraphicsJava2D, drawGeometry() g.vertex() is called 8 times in a loop, inside g.vertex() there is a check, if a break is needed, but this 'break' variable is never true in this case. protected void drawGeometry(PGraphics g) {
// get cache object using g.
g.beginShape(kind);
if (style) {
for (int i = 0; i < vertexCount; i++) {
g.vertex(vertices[i]); // we need a break for i == 4
} I made an example hack, which 'fixes' that problem for JAVA2D and FX2D, by adding an internal breakShape() method. diff --git a/core/src/processing/awt/PGraphicsJava2D.java b/core/src/processing/awt/PGraphicsJava2D.java
index c93ecad..b79f450 100644
--- a/core/src/processing/awt/PGraphicsJava2D.java
+++ b/core/src/processing/awt/PGraphicsJava2D.java
@@ -3007,7 +3007,10 @@
}
-
+ @Override
+ protected void breakShape() {
+ breakShape = true;
+ }
//////////////////////////////////////////////////////////////
// BLEND
diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java
index 65bcb28..dc0f33a 100644
--- a/core/src/processing/core/PGraphics.java
+++ b/core/src/processing/core/PGraphics.java
@@ -8574,4 +8574,8 @@
}
+ protected void breakShape() {
+
+ }
+
}
diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java
index b587e3e..51e23d1 100644
--- a/core/src/processing/core/PShape.java
+++ b/core/src/processing/core/PShape.java
@@ -1717,6 +1717,11 @@
g.beginShape(kind);
if (style) {
for (int i = 0; i < vertexCount; i++) {
+ if (vertexCodeCount > 0) {
+ if (vertexCodes[i] == BREAK) {
+ g.breakShape();
+ }
+ }
g.vertex(vertices[i]);
}
} else {
diff --git a/core/src/processing/javafx/PGraphicsFX2D.java b/core/src/processing/javafx/PGraphicsFX2D.java
index 74758ce..163c5ed 100644
--- a/core/src/processing/javafx/PGraphicsFX2D.java
+++ b/core/src/processing/javafx/PGraphicsFX2D.java
@@ -2290,7 +2290,10 @@
// }
-
+ @Override
+ protected void breakShape() {
+ breakShape = true;
+ }
//////////////////////////////////////////////////////////////
// BLEND |
this code came directly from the processing website (although shortened), yet it still doesnt work. https://processing.org/reference/PShape_beginContour_.html
Processing 3.3
Windows 10, 64-bit
The text was updated successfully, but these errors were encountered: