xxxxxxxxxx
var img;
var x = 0;
var y = 0;
function setup() {
c = createCanvas(640, 480);
background(0);
// activate webcam
img = createCapture(VIDEO); // selfie camera
//img = createCapture({ audio: false, video: { facingMode: { exact: "environment" } }}); // backside camera
img.size(640, 480);
img.hide();
}
function draw() {
//background(255);
//image(img, mouseX, 0);
// Pixel in Speicher laden
img.loadPixels();
//img.updatePixels();
// a one pixel wide column of the current webcam image
// at the current position x
//var line = img.get(x, 0, 1, img.height);
var line = img.get(0, y, img.width, 1);
// displayed at the current position x
//translate(x, 0);
translate(0, random(480));
//rotate(sin(millis()/1000.0));
//tint(y/5, 10, 700);
image(line, 0, 0);
// increment the position x or set to zero (at the end)
if (x < img.width)
x += 1;
else
x = 0;
if (y < img.height)
y += 1;
else
y = 0;
}
function mousePressed()
{
saveCanvas(c, 'screenshot', 'jpg');
}
// rotate(sin(millis()/1000.0));
// translate(random(width), 0);
// translate(width/2+sin(millis()/1000.0)*width/2, 0);