SZE = ~~(min(windowWidth, windowHeight) / N)
createCanvas(~~(windowWidth / SZE) * SZE, ~~(windowHeight / SZE) * SZE);
describe("animation of pixels in a grid by fade, size, brigthness");
pal = [...palettes[frameCount % palettes.length]];
grid3 = makeBrightnessArr();
grids = [grid1, grid2, grid3]
const state = (frameCount/90) % grids.length;
for (let x = 0; x < NX; x++) {
for (let y = 0; y < NY; y++) {
const f = easeInOutBounce(fract(state));
const pxl1 = grids[~~state][x][y];
const pxl2 = grids[(~~state+1)%grids.length][x][y];
x: lerp(pxl1.x, pxl2.x, f),
y: lerp(pxl1.y, pxl2.y, f),
clr: lerpColor(pxl1.clr, pxl2.clr, f),
s: lerp(pxl1.s, pxl2.s, f)
rect(pxl.x, pxl.y, pxl.s)
drawMsg("faded pixels (epi) #genuary2529 [" + (["fade", "size", "brigthness"])[~~state] + "]");
function makeFadedArr() {
for (let x = 0; x < NX; x++) {
let num = ~~random(3, 11);
let currN = ~~random(num);
for (let y = 0; y < NY; y++) {
const s = random(SZE / 4, SZE * 1.1);
const f = map(currN, 0, num - 1, 0, 1);
const clr = lerpColor(color(pal[0]), color(pal[1]), f);
const pxl = { x: x * SZE + SZE / 2, y: y * SZE + SZE / 2, s, clr };
pxls = pxls.sort((a, b) => a.s - b.s);
for (let x = 0; x < NX; x++) {
for (let y = 0; y < NY; y++) {
const pxl = pxls[x*NY+y];
arr[x][y] = {x: x * SZE + SZE / 2, y: y * SZE + SZE / 2, s: pxl.s, clr: pxl.clr};
function makeBrightnessArr() {
pxls = pxls.sort((a, b) => brightness(a.clr) - brightness(b.clr));
for (let x = 0; x < NX; x++) {
for (let y = 0; y < NY; y++) {
const pxl = pxls[x*NY+y];
arr[x][y] = {x: x * SZE + SZE / 2, y: y * SZE + SZE / 2, s: pxl.s, clr: pxl.clr};
save(svg.split("\n"), "epi_sorted_pixels.svg.txt");
function mousePressed() {
if (mouseButton != RIGHT) setup();