Skip to content

Instantly share code, notes, and snippets.

@indefinit
Created March 24, 2026 18:46
Show Gist options
  • Select an option

  • Save indefinit/8cc4595205d1e4f2d273e44d3aa41a94 to your computer and use it in GitHub Desktop.

Select an option

Save indefinit/8cc4595205d1e4f2d273e44d3aa41a94 to your computer and use it in GitHub Desktop.
p5js seconds counter
let lastTime = 0;
let seconds = 0;
function setup() {
createCanvas(400, 400);
textAlign(CENTER, CENTER);
textSize(64);
}
function draw() {
background(30);
if (millis() - lastTime >= 1000) {
seconds++;
lastTime = millis();
}
fill(255);
text(seconds, width / 2, height / 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment