xxxxxxxxxx
let tileSize;
let colors = ['#e06a00', '#000100', '#ff0000']; // Randomly chosen colors for the animation
let frameCount = 0;
function setup() {
createCanvas(1080, 1080);
tileSize = width / 10;
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
let index = int(random(colors.length));
let chosenColor = colors[index];
let pattern = int(random(2)); // Randomly choose a pattern
drawPattern(x * tileSize, y * tileSize, pattern, chosenColor);
}
}
}
function drawPattern(x, y, pattern, color) {
push();
translate(x + tileSize / 2, y + tileSize / 2);
fill(color);
noStroke();
rectMode(CENTER);
switch (pattern) {
case 0: // Pattern 1
for (let i = -10; i <= 10; i += 5) {
for (let j = -10; j <= 10; j += 5) {
ellipse(i, j, 5, 5);
}
}
break;
case 1: // Pattern 2
for (let i = -10; i <= 10; i += 5) {
for (let j = -10; j <= 10; j += 5) {
rect(i, j, 5, 5);
}
}
break;
}
pop();
}
function draw() {
if (frameCount % 2 === 0) { // Update colors every 2 frames
background('#01d801');
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
let index = int(random(colors.length));
let chosenColor = colors[index];
let pattern = int(random(2));
drawPattern(x * tileSize, y * tileSize, pattern, chosenColor);
}
}
}
frameCount++;
}