tapioca24 / p5.capture

🎬 super easy recording for p5.js animations
MIT License
221 stars 6 forks source link

[feature suggestion] Make default frame rate from p5js #14

Open jcubic opened 2 years ago

jcubic commented 2 years ago

I'm not sure if this is possible but in my coding playground prototype:

https://p5.javascript.org.pl/amused-loan?template=none

To record a proper Gif I still need to put P5.capture code in my sketch. Capture frame rate should match frame rate from p5.js

If I want to capture the animation I need to copy paste p5.capture default config:

function setup() {
    createCanvas(400, 400);
    //noLoop();
    frameRate(5);
}

P5Capture.setDefaultOptions({
    disableUi: true,
    format: "gif",
    framerate: 5,
    quality: 0.5,
});

To not break the API, how about -1 value will mean that it should take frameRate from P5.js?

tapioca24 commented 2 years ago

Hi @jcubic, Thank you for your suggestion.

This sounds good. It makes sense to reference the frame rate in p5.js, since generally the animation frame rate and the recording frame rate should match.

My only concern is that the API to get the target frame rate is not exposed by p5.js and must reference a private variable called _targetFrameRate. This means that an update to p5.js could cause it to suddenly stop working. Please give me some time as I need to do a little research on this.

jcubic commented 2 years ago

If P5.js doesn't support the API to allow this, maybe it's worth creating an issue and asking if they are willing to expose the frame rate somehow.

tapioca24 commented 2 years ago

That would be good. I have already created it. https://github.com/processing/p5.js/issues/5762

If I can get approval I would like to start working on it.