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

**URL:** https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139
**Category:** Coding Questions
**Created:** [August 31, 2018, 4:40pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139 "2018-08-31T16:40:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)
#### Post date: [August 31, 2018, 4:40pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/1 "2018-08-31T16:40:29Z")

</div>

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

```auto
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:

 ![01%20AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/71d42287e738fb42895b95fafcef23a9c8689686.png)

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](https://processing.org/reference/bezierVertex_.html) is pretty vague, but _ **does** _ work:

```auto
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](http://processing.github.io/processing-javadocs/core/), so give me enough time and I’ll probably stumble upon the answer.

---

<div class="post-metadata">

### Author: ![WakeMeAtThree](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/wakemeatthree/32/38_2.png) [@WakeMeAtThree](https://discourse.processing.org/u/WakeMeAtThree)
#### Post date: [August 31, 2018, 5:14pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/2 "2018-08-31T17:14:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [August 31, 2018, 5:15pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/3 "2018-08-31T17:15:22Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [August 31, 2018, 5:23pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/4 "2018-08-31T17:23:48Z")

</div>

You can find some answers here:

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/23781/beziervertex-does-not-behave-as-expected-if-stored-as-pshape)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

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

---

<div class="post-metadata">

### Author: ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)
#### Post date: [August 31, 2018, 5:36pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/5 "2018-08-31T17:36:57Z")

</div>

> [@WakeMeAtThree](#):
>
> try `size(512,512,P2D)`

 ![16%20AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d6f1c15c79e52b62a1e261dd5fbd1fed0847923d.png)

> [@jb4x](#):
>
> suggest to use `createShape(PShape.PATH)`

 ![59%20AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2bef9bc65e9da7f956db7931c7a9203fd0c101a6.png)

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()](https://processing.org/reference/createShape_.html) 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

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [September 3, 2018, 2:32am UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/6 "2018-09-03T02:32:17Z")

</div>

@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?

> **[processing/processing](https://github.com/processing/processing/issues)**
>
> Source code for the Processing Core and Development Environment (PDE) - processing/processing

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [September 3, 2018, 5:31am UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/7 "2018-09-03T05:31:38Z")

</div>

Hi @jeremydouglass,

I found this issue:

> <https://github.com/processing/processing/issues/4879>

---

<div class="post-metadata">

### Author: ![msoriaro](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@msoriaro](https://discourse.processing.org/u/msoriaro)
#### Post date: [December 18, 2020, 7:27pm UTC](https://discourse.processing.org/t/beziervertex-draws-straight-lines-not-a-curved-line/3139/8 "2020-12-18T19:27:15Z")

</div>

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!
