float[][] eSize = new float[3][5]; //円のサイズ
//円の拡大縮小のスピード
float[][] speed = {{0.1, 0.5, 0.3, 0.2, 1.5},
{1.0, 2.0, 1.5, 2.0, 0.05},
{0.4, 0.8, 0.08, 1.1, 1.4}};
float minSize = 1.0; //円のサイズの最小値
float maxSize = 100.0; //円のサイズの最大値
void setup() {
size(400, 200);
background(255);
noStroke();
fill(0);
for (int y = 0; y < 3; y++) { //円のサイズを最小値に設定
for (int x = 0; x < 5; x++) {
eSize[y][x] = minSize;
}
}
}
void draw() {
background(255);
for (int y = 0; y < 3; y++) { //列方向
for (int x = 0; x < 5; x++) { //行方向
eSize[y][x] += speed[y][x]; //円のサイズを変化させる
//もし円のサイズが最大値を超えたか最小値未満になったら
//speedの増減を反転させる
if (eSize[y][x] > maxSize || eSize[y][x] < minSize)
speed[y][x] = -speed[y][x];
//yが1,xが3のときだけ赤にする
if (y == 1 && x == 3) {
fill(255, 0, 0);
} else {
fill(0);
}
//円を描く
ellipse(100*x, 100*y, eSize[y][x], eSize[y][x]);
}
}
}