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(32, 24); // this is in pixels
capture.hide(); // telling the browser to hide the camera so we can draw it ourselves
imageout = createImage(32, 24); // 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 x, y;
if(whichway==0) // vertical stripes
{
x = i%(imageout.width*4);
y = imageout.width/2;
}
if(whichway==1) // horizontal stripe
{
x = imageout.width*4/2;
y = floor(i/(imageout.width*4));
}
if(whichway==2) // NORMAL
{
x = i%(imageout.width*4);
y = floor(i/(imageout.width*4));
}
let iptr = x + (y*imageout.width*4);
imageout.pixels[i] = capture.pixels[iptr];
imageout.pixels[i+1] = capture.pixels[iptr+1];
imageout.pixels[i+2] = capture.pixels[iptr+2];
imageout.pixels[i+3] = 255;
}
imageout.updatePixels();
image(imageout, 0, 0, width, height);
}
function keyPressed()
{
whichway = (whichway+1)%3;
}