xxxxxxxxxx
31
let img;
const SIZES = 5;
function preload(){
img = loadImage("redon.jpg")
}
function setup() {
rectMode(CENTER);
img.loadPixels();
createCanvas(img.width, img.height);
noCursor()
}
function draw() {
noStroke()
for(let i=0; i<3000; i++){
let coord = [ max( 0, min(width-1, round(randomGaussian(mouseX,width/4)) ) ) ,
max( 0, min(height-1, round(randomGaussian(mouseY,height/4)) ) ) ]
let mouseDist = sqrt((coord[0] - mouseX) ** 2 + (coord[1] - mouseY) ** 2) / width
let n = min(SIZES-1, max( 0,floor(randomGaussian(SIZES*mouseDist,SIZES/10)) ) );
let size = 2 ** n;
const pixelIndex = 4*coord[1]*img.width + 4*coord[0];
fill(img.pixels[pixelIndex], img.pixels[pixelIndex+1], img.pixels[pixelIndex+2])
rect(coord[0],coord[1],size,size)
}
}