xxxxxxxxxx
44
var boolDoRefresh;
var gridSize = 10;
function preload() {
sad = loadImage('images/icons8-sad-24.png');
smile = loadImage('images/icons8-happy-24.png');
silent = loadImage('images/icons8-silent-24 .png');
}
function setup() {
createCanvas(400, 400);
boolDoRefresh = true;
}
function draw() {
var imgs = [smile, sad, silent ];
var colors = ['#002fff', '#38F71B', 'red', '#ff00ce']
if (boolDoRefresh) {
background(random(colors));
for (let x = 10; x <= width - 30; x += 30) {
for (let y = 10; y <= height - 30; y += 30) {
let num = int(random(0, 10));
let mod1 = int(random(0, 50));
let mod2 = int(random(0, 60));
if(num % mod1 == 0){
image(silent, x, y);
}
else if(num % mod2 == 0){
image(sad, x, y);
}
else{
image(smile, x, y);
}
boolDoRefresh = false;
}
}
}
}
function mousePressed() {
boolDoRefresh = true;
}