Thursday, September 4, 2025
HomeLanguagesJavascriptp5.js frameRate() Function

p5.js frameRate() Function

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() {
    
    // Create canvas of given size
    createCanvas(500, 200);
      
    // Set the font size
    textSize(20);
    
    // Use frameRate() function
    frameRate(3);
}
   
function draw() {
      
    // Set the background color
    background(0, 153, 0);
      
    // Display the output
    text("Frame Count with frameRate " + 
         int(getFrameRate()), 100, 100);
}


Output:

Reference: https://p5js.org/reference/#/p5/frameRate

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6629 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11859 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6717 POSTS0 COMMENTS