xxxxxxxxxx
var capture, imageout;
function setup() {
createCanvas(windowWidth, windowHeight);
capture = createCapture(VIDEO); // this opens up the camera
pixelDensity(1); // turns off oversampling ("retina display")
capture.size(640, 480); // this is in pixels
capture.hide(); // telling the browser to hide the camera so we can draw it ourselves
imageout = createImage(640, 480); // create an empty picture
}
function draw() {
background(0);
capture.loadPixels();
imageout.loadPixels();
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] = max(capture.pixels[iptr], capture.pixels[i]);
imageout.pixels[i+1] = max(capture.pixels[iptr+1], capture.pixels[i+1]);
imageout.pixels[i+2] = max(capture.pixels[iptr+2], capture.pixels[i+2]);
imageout.pixels[i+3] = 255;
}
imageout.updatePixels();
image(imageout, 0, 0, width, height);
}