xxxxxxxxxx
21
/*
* Creative Coding Workshop #5 Demo - Displaying Webcam Feed on Canvas
*
* Jack B. Du (github@jackbdu.com)
*/
let capture;
function setup() {
createCanvas(400, 400);
// create camera feed and load it to capture variable
capture = createCapture(VIDEO);
}
function draw() {
background(220);
// use capture variable same as an image
// COVER ensures the image cover entire canvas by cropping symmetrically
image(capture, 0, 0, width, height, 0, 0, capture.width, capture.height, COVER);
}