p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Add a function to get the target frame rate

Open tapioca24 opened this issue 3 years ago • 3 comments

Increasing Access

I am developing a library for recording p5.js animations and this proposal is to improve it. Many already use this library, and improving its usability should increase the number of sketches posted to Twitter, Instagram, etc., and thus more access to p5.js.

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [X] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Build Process
  • [ ] Unit Testing
  • [ ] Internalization
  • [ ] Friendly Errors
  • [ ] Other (specify if possible)

Feature request details

I am developing a library to record p5.js animations. In a recording library, it makes sense in many use cases to match the recording frame rate to the target frame rate in p5.js.

But it looks like the only way to get the target frame rate is to reference a variable called _targetFrameRate. And this is probably a private variable, not intended for user use. Libraries that depend on private variables in p5.js could suddenly stop working if p5.js is updated, which should be avoided if possible.

It would be great if p5.js supported a function to get the target frame rate as a public API, such as getTargetFrameRate().

tapioca24 avatar Aug 12 '22 07:08 tapioca24

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

welcome[bot] avatar Aug 12 '22 07:08 welcome[bot]

Hi @tapioca24, does the return value of frameRate() (without any arguments) not work in your use case?

limzykenneth avatar Aug 14 '22 09:08 limzykenneth

Hi @limzykenneth, frameRate() does not work in my use case. frameRate() returns an actual measured value, which is different from the target set by the user. This difference is especially noticeable when there is slow processing in the draw function. I need the target frame rate.

tapioca24 avatar Aug 14 '22 13:08 tapioca24

My team is working on this issue

4slk4 avatar Oct 18 '22 02:10 4slk4