xxxxxxxxxx
var capture, imageout;
function setup() {
createCanvas(windowWidth, windowHeight);
capture = createCapture(VIDEO); // opens up the camera
pixelDensity(1); // turns off oversampling ("retina display")
capture.size(32, 32); // in pixels
capture.hide(); // telling the browser to hide the camera so we can draw it ourselves
imageout = createImage(32, 32); // create an empty picture
}
function draw() {
background(0);
capture.loadPixels();
imageout.loadPixels();
noSmooth();
let mult = floor(map(mouseX,0,width,1,20));
for(let i = 0;i<imageout.pixels.length;i+=4)
{
let iptr = i*mult%capture.pixels.length; // where in the input are we
imageout.pixels[i] = random(255);
imageout.pixels[i+1] = random(255);
imageout.pixels[i+2] = random(255);
imageout.pixels[i+3] = 255;
}
imageout.updatePixels();
image(imageout, 0, 0, width, height);
}