bezierVertex() draws straight lines, not a curved line?

I thought I was using bezierVertex() correctly, but what the hey.

void setup()
{
  size(512,512);
  
  PShape bez = createShape();
  bez.beginShape();
  bez.noFill();
  bez.stroke(255,0,0);
  bez.strokeWeight(2);
  bez.vertex(0,0);
  bez.bezierVertex(0.17*width,0.67*width,0.83*width,0.67*width,width,width);
  bez.endShape();
  
  // Trying both methods
  bezier(0,0, 0.17*width,0.67*width,0.83*width,0.67*width,width,width);  
  shape(bez,0,0);
}

And here’s what appears for me:

Obviously, the bezier() function is curved, but bezierVertex(), using the exact same parameters, does not get drawn as it should.

More annoying is that the example from the bezierVertex() reference is pretty vague, but does work:

noFill();
beginShape();
vertex(30, 20);
bezierVertex(80, 0, 80, 75, 30, 75);
endShape();

I haven’t used PShapes that much, so my best guess is that it’s due to some shape-setting I’m unaware of.

I’m still digging through the PShape javadoc, so give me enough time and I’ll probably stumble upon the answer.

1 Like

Hi @tony!
Can you try size(512,512,P2D); and see if that works? That used to resolve it for me before, although there seems to be some kind of flickering issue.

2 Likes

It is working with the P2D renderer.

Well kinda, it is blinking like crazy, but at least you are getting the cruve!

Edit:
Ouppss, haven’t seen @WakeMeAtThree answer. Sorry for that!

1 Like

You can find some answers here:

@rantonse suggest to use createShape(PShape.PATH) for the Java2D renderer.

3 Likes

Interesting. They both work, but createShape(PShape.PATH); definitely renders a better curve. I wonder why?

Also, I got this warning using size(512,512, P2D):

2018-08-31 10:24:49.119 java[70424:4002899] pid(70424)/euid(502) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

What annoys me is that PShape.PATH is not mentioned at all in the createShape() reference.

One of the following parameters are used as the first parameter: ELLIPSE , RECT , ARC , TRIANGLE , SPHERE , BOX , QUAD , or LINE .

Thanks again to @jb4x and @WakeMeAtThree

1 Like

@WakeMeAtThree, @jb4x – do you know if this limitation is documented and/or is there an open issue regarding this not working with the default JAVA2D renderer – or should this be reported as a new issue?

Hi @jeremydouglass,

I found this issue:

2 Likes

Thanks @jb4x for the PShape.PATH solution! The problem still persists in Processing 3.5.4, Python mode, as of today. The bezierVertex seems to work fine with the P2D renderer, but it is working weird in the PDF and SVG renderers too. However, PShape.PATH solves it for all the renderers.

Many thanks again!

2 Likes