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();