xxxxxxxxxx
33
let img;
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
img = loadImage("conclusion.jpg");
}
function draw() {
background(35, 76, 22);
fill(0);
noStroke();
let tiles = 20;
let tileSize = width / tiles;
let ratio = img.width / img.height;
push();
rotateY(radians(frameCount));
for (let x = 0; x < tiles * ratio; 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 - img.width / 2, y * tileSize - img.height / 2, z);
fill(244, 143, 66);
box(tileSize * b * 0.8);
pop();
}
}
pop();
}