# Why doesn't curveVertex work in this PShape

**URL:** https://discourse.processing.org/t/why-doesnt-curvevertex-work-in-this-pshape/6263
**Category:** Coding Questions
**Created:** [December 3, 2018, 6:12pm UTC](https://discourse.processing.org/t/why-doesnt-curvevertex-work-in-this-pshape/6263 "2018-12-03T18:12:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)
#### Post date: [December 3, 2018, 6:12pm UTC](https://discourse.processing.org/t/why-doesnt-curvevertex-work-in-this-pshape/6263/1 "2018-12-03T18:12:57Z")

</div>

I was looking at an example of creating a spiral on the old Processing forum, [drawing a spiral](https://processing.org/discourse/beta/num_1223582667.html)

```auto
size(800,800);
smooth();
translate(width/2,height/2);
strokeWeight(2);
beginShape();
for(int i=0;i<350;i++)
{
  curveVertex((i*2)*sin(i/5.0),(i*2)*cos(i/5.0));
}
endShape(); 

```

I tried to recreate this in a PShape but `curveVertex` seems not to work when used this way, and I would like to know why. Is it just because PShape doesn’t like it for some reason?

So in this example, the “green” one at the end of the sketch doesn’t work unless `curveVertex` is changed to a regular `vertex` as in the “red” one.

```auto
PShape s1, s2;
size(800, 800);
strokeWeight(2);
noFill();

// blue
pushMatrix();
translate(width/4, height/2);
stroke(0, 0, 255);
beginShape();
for (int i=0; i<350; i++)
{
  curveVertex((i*2)*sin(i/5.0), (i*2)*cos(i/5.0));
}
endShape(); 
popMatrix();

// red
pushMatrix();
translate(width/4*2, height/2);
stroke(255, 0, 0);
s1 = createShape();
s1.beginShape();
for (int i=0; i<350; i++) {
  s1.vertex((i*2)*sin(i/5.0), (i*2)*cos(i/5.0));
}
s1.endShape();
shape(s1);
popMatrix();

// green
pushMatrix();
translate(width/4*3, height/2);
stroke(0, 255, 0);
s2 = createShape();
s2.beginShape();
for (int i=0; i<350; i++) {
  s2.curveVertex((i*2)*sin(i/5.0), (i*2)*cos(i/5.0));
}
s2.endShape();
shape(s2);
popMatrix();

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [December 3, 2018, 7:45pm UTC](https://discourse.processing.org/t/why-doesnt-curvevertex-work-in-this-pshape/6263/2 "2018-12-03T19:45:58Z")

</div>

there is some old info you can find with google  
that the combination of  
PShape and curveVertex  
only run with P2D

```auto
PShape s1, s2;

void setup() {
  size(500, 500, P2D);
  strokeWeight(2);
  noFill();
  translate(width/2, height/2);
  // red
  stroke(255, 0, 0);
  s1 = createShape();
  s1.beginShape();
  for (int i=0; i<350; i++) 
    s1.vertex((i*2)*sin(i/5.0), (i*2)*cos(i/5.0));
  s1.endShape();

  // green
  stroke(0, 255, 0);
  s2 = createShape();
  s2.beginShape();
  for (int i=0; i<350; i++) {
    s2.curveVertex((i*2)*sin(i/5.0), (i*2)*cos(i/5.0));
  }
  s2.endShape();
  // blue
  stroke(0, 0, 255);
  beginShape();
  for (int i=0; i<350; i++)
    curveVertex((i*2)*sin(i/5.0), (i*2)*cos(i/5.0));
  endShape(); 
// draw s1,s2
  shape(s1, 20, 0);
  shape(s2, 40, 0);
}

```

---

<div class="post-metadata">

### Author: ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)
#### Post date: [December 4, 2018, 3:28am UTC](https://discourse.processing.org/t/why-doesnt-curvevertex-work-in-this-pshape/6263/3 "2018-12-04T03:28:11Z")

</div>

Ah! Thanks very much
