xxxxxxxxxx
var capture, imageout;
var whichway = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
capture = createCapture(VIDEO); // this opens up the camera
pixelDensity(1); // turns off oversampling ("retina display")
capture.size(320, 240); // this is in pixels
capture.hide(); // telling the browser to hide the camera so we can draw it ourselves
imageout = createImage(320, 240); // create an empty picture
}
function draw() {
background(0);
capture.loadPixels();
imageout.loadPixels();
let bluramt = mouseX/width;
for(let i = 0;i<imageout.pixels.length;i+=4)
{
imageout.pixels[i] = bluramt*imageout.pixels[i] + (1.0-bluramt)*capture.pixels[i];
imageout.pixels[i+1] = bluramt*imageout.pixels[i+1] + (1.0-bluramt)*capture.pixels[i+1];
imageout.pixels[i+2] = bluramt*imageout.pixels[i+2] + (1.0-bluramt)*capture.pixels[i+2];
imageout.pixels[i+3] = 255;
}
imageout.updatePixels();
image(imageout, 0, 0, width, height);
}
function keyPressed()
{
whichway = (whichway+1)%3;
}