I apologise. I know this topic has been covered several times in various forms in this forum. Unfortunately, after several readings, I seem to miss the point. As a result, my timing in the sketch turns out to be wrong. With one mouse click, the square in the center of the background should slowly rotate HALF_PI. The point here is “slow”. For that I have provided a rotation of HALF_PI/15 that has to be executed 15 times with a short delay of 0.25 sec so that the entire rotation takes 3.75 sec. Unfortunately, the rotation doesn’t seem to be running.
// processing 4.1.1.
// Shapes
PShape block;
// timing
int timeStart;
int timeElapsed;
void setup() {
size(200, 200, P2D);
timeStart = millis();
rectMode(CENTER);
block = createShape(RECT, 0, 0, 50, 50);
block.setFill(color(255));
}
void draw() {
background(50);
translate(width/2, height/2);
shape(block, 0, 0);
}
void mouseClicked() {
timeStart = millis();
int i = 0;
while (i < 16) {
timeElapsed = millis() - timeStart;
if (timeElapsed > 250) {
println(timeElapsed);
block.rotate(HALF_PI / 15);
timeStart = millis();
i = i + 1;
println(i);
}
}
}