var colors = ["#ff8ba6", "#db3b60", "#0b7ca9"];
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));
colors2 = colors.map(c => {
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 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})
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/4));
grid.shapes.forEach(shape => {
shape.color = colors[shape.number];
shape.color2 = colors2[shape.number];
grid.shapes.forEach(shape => {
shape.forEach(coord => vertex(coord.x, coord.y));
values.forEach((v, index) => {
var x = index % itensPerRow + 0.5;
var y = floor(index / itensPerRow) + 0.5;
circle(x * GRID_SIZE, y * GRID_SIZE, GRID_SIZE/6);
walkers.forEach((w, i) => {
w.easeX += (w.x - w.easeX) * 0.3;
w.easeY += (w.y - w.easeY) * 0.3;
stroke(colors[w.number]);
circle((w.easeX + 0.5) * GRID_SIZE, (w.easeY + 0.5) * GRID_SIZE, GRID_SIZE/2);
const x = floor(mouseX/width*itensPerRow);
const y = floor(mouseY/height*itensPerColumn);
walkers.push({x, y, number: floor(random(number_of_types)), easeX: x, easeY: y});