夜更かし
var ball_num;
var ballX = [];
var ballY = [];
var speedX = [];
var speedY = [];
var ball_color = [];
var ball_diameter = [];
var colors = [];
function setup() {
createCanvas(windowWidth,
windowHeight);
ball_num = 700;
colors.push(color(128, 192, 255));
colors.push(color(255, 64, 255));
colors.push(color(0, 255, 255));
colors.push(color(0, 192, 192));
colors.push(color(128, 255, 192));
colors.push(color(0, 192, 192));
colors.push(color(0, 128, 255));
for (var i = 0; i < ball_num; i = i + 1) {
ballX[i] = random(1, windowWidth);
ballY[i] = random(0, windowHeight);
speedX[i] = random(0.1, 1.0);
speedY[i] = random(0.5, 0.5);
ball_color[i] = floor(random(0, colors.length));
ball_diameter[i] = random(10, 80);
}
}
function draw() {
background(128, 128, 255, 255);
noStroke();
for (var i = 0; i < ball_num; i++) {
ballX[i] = ballX[i] + speedX[i];
ballY[i] = ballY[i] + speedY[i];
if (ballX[i] > windowWidth || ballX[i] < 0) {
speedX[i] = -1 * speedX[i];
}
if (ballY[i] > windowHeight || ballY[i] < 0) {
speedY[i] = -1 * speedY[i];
}
}
for (var i = 0; i < ball_num; i++) {
fill(colors[ball_color[i]]);
ellipse(ballX[i], ballY[i], ball_diameter[i]);
}
}