with “void display()”:
Here is the result of me playing around
Version 1 - based on frameCount
Version 1
float s = 5, w = 500/s;
void setup() {
size(500, 500);
}
void draw() {
background(0);
display((frameCount-1)*10,w,s);
}
void display(int fc,float w, float s) {
noStroke();
rect(0,0,width,(floor(fc/w))*s);
for(int i = 0; i < fc % w; i++) {
square(i*s,floor(fc/w)*s,s);
}
}
Version 2 - based on millis(): (takes 20 sec for the whole screen)
Version 2
int totalTime = 20000; //20 seconds
float s = 5, w = 500/s;
void setup() {
size(500, 500);
}
void draw() {
background(0);
display(( map(millis()*0.5,0,totalTime,0,(width/s)*(height/s)) ),w,s);
}
void display(float fc,float w, float s) {
noStroke();
rect(0,0,width,(floor(fc/w))*s);
for(int i = 0; i < fc % w; i++) {
square(i*s,floor(fc/w)*s,s);
}
}
void mousePressed() { println(millis()); }
version 3: (smooth, not square by square)
Version 3
int totalTime = 20000; //20 seconds
float s = 50, w = 500/s;
void setup() {
size(500, 500);
}
void draw() {
background(0);
display(( map(millis(),0,totalTime,0,(width/s)*(height/s)) ),w,s);
}
void display(float fc,float w, float s) {
noStroke();
rect(0,0,width,(floor(fc/w))*s);
rect(0,floor(fc/w)*s,s*(fc%w),s);
}
void mousePressed() { println(millis()); }
version 4: (smooth on x AND y axis)
Version 4
int totalTime = 20000; //20 seconds
float s = 50, w = 500/s;
void setup() {
size(500, 500);
}
void draw() {
background(0);
display(( map(millis(),0,totalTime,0,(width/s)*(height/s)) ),w,s);
}
void display(float fc,float w, float s) {
noStroke();
rect(0,0,width,((fc/w))*s);
rect(0,floor(fc/w)*s,s*(fc%w),s);
}
void mousePressed() { println(millis()); }