xxxxxxxxxx
30
function setup() {
createCanvas(400, 400);
vid = createCapture(VIDEO);
vid.hide();
}
function draw() {
background(220);
image(vid, 0, 0);
vid.loadPixels();
// for (let i = 0; i < video.pixels.length; i += 4) {}
for (let x = 0; x < vid.width; x += 10) {
for (let y = 0; y < vid.height; y += 10) {
let i = 4 * (y*width + x);
let r = vid.pixels[i];
let g = vid.pixels[i + 1];
let b = vid.pixels[i + 2];
let a = vid.pixels[i + 3];
let colorFromVideo = vid.get(x,y);
fill(colorFromVideo);
rect(x, y, 40, 40);
}
}
}
// for(let i = 135 * cat.width*4; i < 136* cat.width*4; i++){
// myImage.pixels[i] = 0;
// }