xxxxxxxxxx
26
let fingers;
function setup() {
createCanvas(320, 240);
// specify multiple formats for different browsers
fingers = loadImage('moving.jpg');
noStroke();
fill(0);
}
function draw() {
background(255);
fingers.loadPixels();
const stepSize = round(constrain(mouseX / 8, 6, 32));
for (let y = 0; y < height; y += stepSize) {
for (let x = 0; x < width; x += stepSize) {
const i = y * width + x;
const darkness = (255 - fingers.pixels[i * 4]) / 255;
const radius = stepSize * darkness;
ellipse(x, y, radius, radius);
}
}
let fps = frameRate();
text("FPS: " + fps.toFixed(2), 10, height - 10);
}