var colors = ["#EBC14D","#E78A5D","#C1497D","#8E5AD8","#578BDF"];
const GRID_SIZE = Math.min(innerWidth, innerHeight) / GRID_UNITS;
const number_of_types = colors.length;
var itensPerRow, itensPerColumn;
describe("An abstract art piece with colorful shapes that move and change dynamically. It utilizes a grid-based system where each grid cell can have one of several colors. As the program runs, colored shapes evolve across the canvas, creating an ever-changing visual experience.");
createCanvas(windowWidth, windowHeight);
strokeWeight(GRID_SIZE/8);
colors.forEach((str, i) => colors[i] = color(str));
colors.forEach(c => c.setAlpha(30))
for(var y = 0; y < height-2; y += GRID_SIZE) {
for(var x = 0; x < width-2; x += GRID_SIZE) {
values.push(floor(random(number_of_types)))
for(var i = 0; i < 10; i++){
for(var number = 0; number < number_of_types; number++){
const x = floor(random(itensPerRow));
const y = floor(random(itensPerColumn));
walkers.push({x, y, number, easeX: x, easeY: y})
for(var i = 0; i < 100; i++){
if(random([true, false]))
w.x = constrain(w.x + random([-1, 1]), 0, itensPerRow-1);
w.y = constrain(w.y + random([-1, 1]), 0, itensPerColumn-1);
values[w.y * itensPerRow + w.x] = w.number;
for(var i = 0; i < 100; i++){
if(random([true, false]))
w.x = constrain(w.x + random([-1, 1]), 0, itensPerRow-1);
w.y = constrain(w.y + random([-1, 1]), 0, itensPerColumn-1);
values[w.y * itensPerRow + w.x] = w.number;
grid = new Grid(GRID_SIZE, width-2, height-2, number_of_types, values);
grid.shapes = grid.shapes.map(shape => grid.shrinkPolygon(shape, GRID_SIZE/3));
grid.shapes.forEach(shape => {
shape.color = colors[shape.number];
for(var i = 0; i < 20; i++){
grid.shapes.forEach(shape => {
shape.forEach(coord => vertex(coord.x, coord.y));