frameCount

Examples

void setup() {
  frameRate(5);
  fill(0);
}

void draw() {
  background(255);

  line(0, 0, sketchWidth, sketchHeight);

  // C-style string
  char str[6];
  snprintf(str, 6, "%ld", frameCount);
  
  text(str, 10, 10);
}

Description

The system variable frameCount contains the number of frames that have been displayed since the program started. Inside setup() the value is 0, after the first iteration of draw it is 1, etc.

Related

frameRate()

Back to index