xxxxxxxxxx
102
let capture;
let x = 0;
let fast = 0;
let bLoop = true;
let bFlip = false;
let flipCounter = 0;
let shift;
// noise wave
let xoff1 = 0;
let xoff2 = 10000;
let inc = 0.003;
let start = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 360, 100, 100, 100);
background(0);
capture = createCapture(VIDEO);
capture.size(windowWidth,windowHeight);
capture.hide();
}
function draw() {
//image(capture, 0, 0, 320, 240);
console.log(frameCount);
let w = capture.width;
let h = int(capture.height);
fast = 0.5;
if(!bFlip) {
copy(capture, w/2, 0, 1, h, x, 0, 1, h);
} else {
copy(capture, 0,w/2, h, 1, 0, x, h, 1);
}
x += fast;
if (bLoop == true && x >= width) {
x = 0;
}
if (frameCount%int(random(500,1000))==0){
bFlip = !bFlip;
}
//noise wave
let xoff = start;
beginShape();
for (let x = 0; x < width; x++){
//fill(0);
var y = noise(xoff) * height;
let shade = map(y, 0, height*.75, 100, 0);
noStroke();
strokeWeight(5);
stroke(0);
fill(0, 100, 50, 10);
vertex(x, y);
xoff += inc;
}
endShape();
start += inc;
}
function keyPressed(){
if (key == 'l') {
bLoop = !bLoop;
x = 0;
fast = 1;
}
if (key == 'f') {
bFlip = !bFlip;
}
}
function touchStarted() {
x = 0;
fast = 1;
flipCounter++;
flipCounter %= 2;
if (flipCounter == 1) {
bFlip = !bFlip;
}
console.log("flipCounter: " + flipCounter);
return false;
}