xxxxxxxxxx
37
let colors = ["rgb(255,255,0)", "rgb(0,128,255)", "rgb(178,102,255)"];
function setup() {
createCanvas(400, 400);
background(0);
}
function draw() {
for (let x = width; x > 0; x -= 30) {
for (let y = height; y > 0; y -= 30) {
if (keyIsPressed) {
let whichColor = int(random(0, colors.length));
fill(colors[whichColor]);
} else {
fill(255);
}
if (mouseIsPressed) {
clear();
background(0);
noStroke();
for (let i = 0; i < 50; i++) {
fill(random(255), random(255), random(255));
ellipse(random(width), random(height), random(100));
}
} else {
circle(x, y, random(2, 20));
}
}
}
}
function mouseReleased()
{
//clear();
// background(0);
}