Skip to content
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

mixing vertex() and curveVertex() #906

Closed
shiffman opened this issue Sep 11, 2015 · 10 comments
Closed

mixing vertex() and curveVertex() #906

shiffman opened this issue Sep 11, 2015 · 10 comments

Comments

@shiffman
Copy link
Member

First, let me say that I don't really know what I'm talking about here. But I noticed today that if you use a call to curveVertex() within beginShape() and endShape(), all the vertices turn into "curved" ones, rather than just an individual vertex, i.e.

screen shot 2015-09-11 at 1 37 22 pm

screen shot 2015-09-11 at 1 37 31 pm

I know there are other aspects at play here in terms of how curveVertex() works, but I'm not sure if the above result is correct?

fill(255);
beginShape();
vertex(30, 10);
curveVertex(85, 20);
vertex(83, 75);
vertex(30, 92);
vertex(50,50);
endShape(CLOSE);
@lmccart
Copy link
Member

lmccart commented Sep 11, 2015

I don't think this behavior is supported in Processing either. When I tried running that code, it seemed to ignore the curveVertex() point completely.
screen shot 2015-09-11 at 1 41 07 pm

Maybe we just need to be clearer in the documentation that you can't mix? Or do you think it is important to support this?

@shiffman
Copy link
Member Author

Yes, I think you are right. My memory tells me there's a way of mixing in Processing, but perhaps that's part of PShape or else involves beginContour() or some other magic I'm not aware. But looking through the Processing examples and documentation I don't see that mixing is allowed like came up in class above. @codeanticode can you provide any guidance?

This may be a edge case that rarely comes up, and I agree it looks like it's a documentation issue.

@codeanticode
Copy link
Member

You can mix regular and curve vertices in Processing:

size(200, 200);

fill(255);

noFill();
beginShape();
curveVertex(84,  91);
curveVertex(84,  91);
curveVertex(68,  19);
curveVertex(21,  17);
curveVertex(32, 100);
curveVertex(32, 100);
vertex(50, 120);
vertex(80, 140);
endShape();

the problem is that you need at least four consecutive curveVertex() calls to draw a valid curve segment

@shiffman
Copy link
Member Author

Thanks, @codeanticode. I am not sure what p5.js should do, just noting the difference. I suppose mixing would be nice if it's reasonable to implement in canvas. See results in both below.

function setup() {
  createCanvas(200, 200);
}

function draw() {
  fill(255);
  noFill();
  beginShape();
  curveVertex(84, 91);
  curveVertex(84, 91);
  curveVertex(68, 19);
  curveVertex(21, 17);
  curveVertex(32, 100);
  curveVertex(32, 100);
  vertex(50, 120);
  vertex(80, 140);
  vertex(100, 140);
  vertex(120, 180);
  vertex(160, 200);
  endShape();
}

screen shot 2015-09-11 at 4 54 49 pm

@arihantparsoya
Copy link
Contributor

@shiffman I submitted a PR(#1185) and hope to get your feedback on my patch soon so i could make necessary changes.

@lmccart
Copy link
Member

lmccart commented Mar 25, 2017

I think the complexity of adding this and the lack of activity on this thread suggests we table this for now and focus on frying bigger fish until this comes into higher demand.

@lmccart lmccart closed this as completed Mar 25, 2017
@rubyjlp
Copy link

rubyjlp commented Oct 25, 2017

Not to reopen this can of worms, but I'm having a lot of problems with this issue. My main problem is that if there are curve vertices within a contour in a custom shape the external shape is also given curves and becomes connected to the contour shape, regardless of whether or not it had curves to begin with. This makes it beyond annoying to make a shape that's, say, a rectangle with a circle cut out from the middle. Examples included: Image of a custom shape with a contour that is only straight lines, and an image of the same shape with one of the vertices changed to a curve vertex.
screen shot 2017-10-24 at 7 10 52 pm
screen shot 2017-10-24 at 7 11 12 pm

@jlp6k
Copy link

jlp6k commented Nov 19, 2017

I have the same problem.
I worked it around with a combination of createGraphics and blendMode() in order to hollow the outer shape with the inner one. But this solution isn't generic as blend mode has to be chosen wrt the colors of the two objects.

@jlp6k jlp6k mentioned this issue Nov 20, 2017
17 tasks
@hapiel
Copy link

hapiel commented Jan 13, 2021

I have also run into a similar issue, I assumed that I could put a curveVertex() within a beginContour(), but this seems to be impossible no matter if the original vertex is curve points or normal points.

My solution has been to approach the curve shape with straight lines between multiple curvePoint()

I would recommend this solution for any problem where you try to mix curveVertex() and vertex(), or where you try to use curveVertex() inside beginContour().

I attempted the createGraphics() and blendMode() solution as suggested above, but this was not feasible when trying to draw a large amount of objects.

@davepagurek
Copy link
Contributor

This is now resolved in 2.0 after #7373!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants