PShape.translate does not seem to update vertex position. Bug?
in
Core Library Questions
•
7 months ago
In the code below I am making translations to a line and printing the line's x coordinate. The value that is printed never changes even though the line is clearly moving on the screen. Is this a bug?
PShape shape;
boolean left = false;
int count = 0;
void setup() {
size(1280, 720, P2D);
shape = createShape();
shape.beginShape();
shape.stroke(0);
shape.strokeWeight(10);
shape.vertex(0, 0);
shape.vertex(0, height);
shape.endShape();
}
void draw() {
background(255);
if (left)
shape.translate(-1, 0);
else
shape.translate(1, 0);
count++;
if (count == width) {
left = !left;
count = 0;
}
shape(shape);
println(shape.getVertexX(0));
}
1