p5.js | frameCount Variable
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.
Syntax:
frameCount
Below program illustrates the frameCount Variable in p5.js:
Example: This example uses frameCount variable to display the frame count.
function setup() {
createCanvas(400, 400);
textSize(40);
textAlign(CENTER);
frameRate(0.5);
}
function draw() {
background(220);
fill( 'green' );
text( "Frame Count: \n" + frameCount,
width / 2, height / 2);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/frameCount
Last Updated :
16 Apr, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...