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); //HORIZONTAL
var line = img.get(0, y, img.width, 1);//VERTIKAL
// displayed at the current position x
//translate(x, 0); //HORIZONTAL
translate(0, y); //VERTIKAL
//rotate(millis()/500); //Bild rotiert sich
scale(sin(millis()/1000)); //Bild wird größer und dann wieder kleiner skaliert
//tint(y/2, 10, 50); //FARBFILTER
//filter(INVERT); //Bild bekommt einen Filter https://p5js.org/reference/#/p5/filter
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 += random(1,480); //die Zeilen werden zufällig aufgebaut
y += 1; //die Zeilen werden von oben nach unten aufgebaut
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);