Spaces:
Sleeping
Sleeping
File size: 843 Bytes
807bb16 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
let video;
function setup() {
createCanvas(400, 300);
video = createCapture(VIDEO);
video.hide();
video.loop();
}
function draw() {
background(0);
let stepSize = floor(map(mouseX, 0, width, 4, 40));
video.loadPixels();
for (let x = 0; x < video.width; x += stepSize) {
for (let y = 0; y < video.height; y += stepSize) {
let i = (y * video.width + x) * 4;
let r = video.pixels[i];
let g = video.pixels[i+1];
let b = video.pixels[i+2];
let a = video.pixels[i+3];
let luma = 0.299 * r + 0.587 * g + 0.114 * b;
let diameter = map(luma, 0, 255, 0, stepSize);
fill(255);
noStroke();
ellipse(
map(x, 0, video.width, 0, width),
map(y, 0, video.height, 0, height),
diameter,
diameter
);
}
}
} |