We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to create a persistance of vision file with for example a red box that appears for a few milliseconds against a black background. I'm used to programming languages that have a delay statement that would pause the program, but Processing works differently. So how would I have a box appear briefly?
nt x=320; int y= 180; int wide=320; int tall= 180;
void setup() { size(1240,720); background(0); stroke(0); }
void draw() { fill(255, 0, 255); rect(x, y, wide, tall); delay (20);
fill(0,255,0);
rect(x, y, wide, tall);
delay(5000);
}
Answers
First, you need to move background to the beginning of the draw, so each frame your sketch would be updated.
Second, you don't need to use delay at all in processing in most cases, cause it freezes entire program stopping event listeners, etc.
Third, you can use millis() to get the time since sketch passed. Read this thread, it explains how to deal with time in processing.