xxxxxxxxxx
38
let img;
let sorted;
let step = 10;
let noiseScale = 0.001;
let noiseLevel;
function preload() {
img = loadImage("PixelPush.png");
}
function setup() {
createCanvas(800, 800);
rectMode(CENTER);
background(0);
noiseLevel = img.width;
img.loadPixels();
for (let i = 0; i < img.width; i += step) {
for (let j = 0; j < img.height; j += step) {
let colorSwap = img.get(i, j);
let nx = noiseScale * i;
let ny = noiseScale * j;
let n = noiseLevel * noise(nx, ny);
noStroke();
fill(colorSwap);
square(i, j, n);
}
}
}
function keyPressed() {
if (key === 's') {
saveFrames('frame', 'png', 1, 2);
}
}