xxxxxxxxxx
35
let img;
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
img = loadImage("gallery-2.jpg");
img.resize(900, 900);
}
function draw() {
background(255);
fill(0);
noStroke();
//sphereDetail(3);
let tiles = 50;
let tileSize = width/tiles;
push();
// translate(width/2,height/2);
rotateY(radians(frameCount));
for (let x = 0; x < tiles; x++) {
for (let y = 0; y < tiles; y++) {
let c = img.get(int(x*tileSize),int(y*tileSize));
let b = map(brightness(c),0,255,1,0);
let z = map(b,0,1,-150,150);
push();
translate(x*tileSize - width/2, y*tileSize - height/2, z);
sphere(tileSize*b*0.8);
pop();
}
}
pop();
}