void setup() {
size(200, 200);
noStroke();
}
void draw() {
background(0);
float cx = width/2, cy = height * 2.0 / 3;
fill(12, 255, 255);
int[] counts = {0, 1, 2, 3, 4, 4, 3, 2, 1, 0};
int P = int(frameCount / 30 / 2 % 10), count = counts[P];
float A = cos(frameCount * PI/2 / 30.0) / 2 + 0.5, angle = -3*PI/4 + A*PI/2;
for (int i = 0; i < 5; i++) {
float r = 20 * i, x = cx + r*cos(angle), y = cy + r*sin(angle);
ellipse(x, y, 10, 10);
if (i <= count) {
float start = -3*PI/4, end = -3*PI/4 + PI/2;
if (i == count) {
if ( i % 2 != 0) {
start = -3*PI/4;
end = -3*PI/4 + A*PI/2;
} else {
start = -3*PI/4 + A*PI/2;
end = -3*PI/4 + PI/2;
}
}
for (int j = 0, N = 40; j < N; j++) {
float angle2 = start + (end-start)*j/N;
float xx = cx + r*cos(angle2);
float yy = cy + r*sin(angle2);
ellipse(xx, yy, 10, 10);
}
}
}
}