xxxxxxxxxx
18
let capture;
function setup() {
createCanvas(200, 200);
capture = createCapture(VIDEO);
capture.hide();
}
function draw() {
image(capture, // what image to display
0, 0, // where to place the image on the canvas
width, // width to display
// the height is more complicated:
// we want the capture height to be
// the width multiplied by the aspect ratio
capture.height * width / capture.width);
}