# Why doesn't curveVertex work in this PShape

I was looking at an example of creating a spiral on the old Processing forum, drawing a spiral

``````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.

``````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();
``````
1 Like

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

``````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);
}

``````
1 Like

Ah! Thanks very much