xxxxxxxxxx
32
let fps = 60;
let capturer = new CCapture({ format: 'png', framerate: fps });
let doneCapturing = false;
let firstFrame = true;
let canvas;
let frame = 0;
function setup() {
canvas = createCanvas(400, 400);
}
function draw() {
if (firstFrame) {
capturer.start();
firstFrame = false;
}
capturer.capture( document.getElementById(canvas.id() ));
frame++;
if (frame > 60) {doneCapturing = true;}
if (doneCapturing) {
capturer.stop();
capturer.save();
background(0);
noLoop();
}
}