Skip to content
Related Articles

Related Articles

Improve Article

p5.js | frameCount Variable

  • Last Updated : 16 Apr, 2019
Geek Week

The frameCount variable in p5.js is used to hold the number of frames which are displayed since the program started. Inside setup() function the value is 0, after the first iteration of draw it is 1, etc.



Below program illustrates the frameCount Variable in p5.js:

Example: This example uses frameCount variable to display the frame count.

function setup() {
    // Create canvas of given size
    createCanvas(400, 400);
    // Set text size to 40px
    // Align text to center 
    // Set Frame Rate to 0.5  
function draw() {
    // Set background color
    // Set color of text
    // Use frameCount Variable
    text("Frame Count: \n" + frameCount, 
            width / 2, height / 2); 



Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :