xxxxxxxxxx
70
let myVideo;
let p5lm;
function setup() {
createCanvas(400, 400);
p5lm = new p5LiveMedia(this, null, null, "myCoolRoom")
p5lm.on("STREAM", gotRemoteStream);
myVideo = createCapture(VIDEO, gotStream)
myVideo.hide()
}
function gotStream(stream){
console.log('Just got webcam stream!');
p5lm.addStream(stream, "CAPTURE");
}
function gotRemoteStream(stream){
console.log('I got a remote stream');
}
function draw() {
background(200,100,255);
// image(myVideo,20,30,150,200);
// for (let i = 0; i < 10; i++){
// image(myVideo,i * 20,i * 30,150,200);
// }
// image(myVideo,mouseX,mouseY,100,100)
// for (let x = 0; x < 4; x++){
// for (let y = 0; y < 4; y++){
// image(myVideo,x * 100,y* 100,100,100);
// }
// }
push(); // create certain transformations here
let xOffset = 100 + sin(frameCount/100) * 50;
translate(xOffset,100);
stroke(255,0,0);
strokeWeight(10);
rect(0,0,200,100)
image(myVideo,0,0,100,100);
image(myVideo,100,0,100,100);
pop(); // transformations are un-done here
// draw image a 2nd time
// image(myVideo,0,0,100,100);
}