p5.js frameRate() Function
Last Updated :
10 Aug, 2023
The frameRate() function in p5.js is used to specify the number of frames to be displayed every second. Calling frameRate() with no arguments returns the current framerate. The draw function must run at least once before it will return a value. This function is same as getFrameRate() function.
Syntax
frameRate( c )
Parameters: The function accepts single parameter c which stores the value of frame rate variable.
Below program illustrates the frameRate() function in p5.js:
Example:
function setup() {
createCanvas(500, 200);
textSize(20);
frameRate(3);
}
function draw() {
background(0, 153, 0);
text( "Frame Count with frameRate " +
int(getFrameRate()), 100, 100);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/frameRate
Share your thoughts in the comments
Please Login to comment...