xxxxxxxxxx
53
/*
This script can render avi's and gifs. Setup recording in setup().
Press enter to start and stop recording.
Will also stop recording after recording 'FRAMES' frames. Use this for perfect loops :)
libraries used:
Video Builder: https://github.com/theshock/VideoBuilder
download: https://github.com/rndme/download
*/
const FRAMES = 300;
const FPS = 60;
let rec;
let size;
function setup() {
size = min(windowWidth, windowHeight); // fill window
// size = 1080;
const canvas = createCanvas(size, size);
frameRate(FPS);
rec = setupRecording("you should name me", canvas, FRAMES, {
avi: {
fps: 60,
quality: 1
},
});
}
function keyPressed(evt) {
if (evt.key == "Enter") {
if (!rec.recording) {
rec.start();
frameCount = 0; // reset time
} else
rec.stop();
}
}
let t;
function draw() {
t = fract(frameCount / FRAMES);
drawScene();
if (rec.recording)
rec.recordFrame();
}
function drawScene() {
// your drawing code here
}