p5-export
v1.0.0
Published
This wrapper can help you easely export your p5.js sketch as a webm video using CCapture.js
Downloads
9
Readme
p5.js Sketch Export
This wrapper can help you easely export your p5.js sketch as a webm video using CCapture.js library.
It can also be used to record interactions (eg. mouse interactions, music interaction) before the final export.
Demo
Check the demo and open the console in the browser.
Add ?export=true
to the url to start the export.
Full url:
https://lucacattan3o.github.io/p5.js-export/demo/index.html?export=true
Setup
Load CCapture and sketch-export in your project.
<script src="CCapture.all.min.js"></script>
<script src="sketch-export.js"></script>
<script src="sketch.js"></script>
Inside sketch.js
, use sketchExportSetup()
to instantiate the exporter and set the framerate equal to the sketch framerate.
let fps = 30;
function setup() {
createCanvas(1080, 1080);
frameRate(fps);
sketchExportSetup({
fps: fps
})
}
A the end of draw()
use this pattern:
function draw() {
// Your visual here
// Start the export
if (frameCount == 1){
sketchExportStart();
}
// Capture the frame
sketchExport();
// Stop the export after 6 seconds
if (frameCount == 6 * fps){
sketchExportEnd();
}
}
The sketch is now ready to be exported.
Export the sketch
To start the export, add ?export=true
to the url. Example:
http://127.0.0.1:5500/demo/?export=true
Open the browser console to see the export progress.
Record interactions
TBD