// caleb b
// Progress bar
Particle[] particles = new Particle[15]; // initialize particles
void setup() {
// set size framerate and background
size(1024, 1024);
frameRate(24);
background(0, 0, 0);
// draw the unfinished progress bar
rect((1024/2) - 400, (1024/2) - 50, 800, 100);
// add particles to array
for(int i = 0; i < 15; i++) {
particles[i] = new Particle();
}
}
void draw() {
float progress = (millis() * 800 / 10000); // calculate the progress of the bar
if (progress > 800) progress = 800; // ensure progress does not go over the maximum size
fill(0, 255, 0); // set color to green
rect((1024/2) - 400, (1024/2) - 50, progress, 100); // draw the progress
if (progress == 800) {
// when the bar is complete, draw the Complete text and draw particles
textSize(50);
text("Complete!", 1024/2 - 100, 1024/2 + 100);
for (Particle p : particles) {
// i added particles for fun
fill(p.r, p.g, p.b);
ellipse(p.x, p.y, 10, 10);
p.x += random(-3, 3);
p.y += random(-3, 3);
}
}
}
class Particle {
float x = random(0, 1024);
float y = random(0, 1024);
float r = random(0,256);
float g = random(0,256);
float b = random(0,256);
}
int mins = 0;
int seconds = 0;
// caleb b
// stopwatch
void setup() {
size(500, 500);
background(255,255,255);
fill(0,0,0);
textSize(50);
frameRate(1);
text("00:00", 500/2 - 50, 500/2 - 50);
}
void draw() {
background(255,255,255);
fill(0,0,0);
// every 1000ms, add 1 to seconds
seconds++;
if (seconds >= 60) {
seconds = 0;
mins++;
}
String minutes = nf(mins, 2);
String secondsStr = nf(seconds, 2);
textSize(50);
text(minutes + ":" + secondsStr, 500/2 - 50, 500/2 - 50);
}