[gallery]
A progress indicator in Processing.
int width = 128;
int height = 128;
float amount = 1.0;
float spokes = 0;
boolean storeResults = true;
void setup () {
size(width, height);
}
void draw () {
fill(0, 0, 0);
rect(0, 0, width, height);
stroke(255, 255, 255, 128);
fill(255, 255, 255, 128);
float cx, cy;
cx = width * 0.5;
cy = height * 0.5;
for (int i = 0; i < amount * spokes; i++) {
float angle = i * TWO_PI / (amount * 360);
float x = cx + cos(angle) * (cx * 0.9);
float y = cy + sin(angle) * (cy * 0.9);
float x2 = cx + cos(angle) * (cx * 0.1);
float y2 = cy + sin(angle) * (cy * 0.1);
point(x, y);
DrawLine(x, y, x2, y2);
}
spokes++;
}
void DrawLine (float fx, float fy, float tx, float ty){
float res = width * 0.9;
for (int i = 0; i < res; i++) {
float x = lerp(fx, tx, i / res);
float y = lerp(fy, ty, i / res);
rect (x, y, 1, 1);
}
}