Created
March 24, 2026 18:46
-
-
Save indefinit/8cc4595205d1e4f2d273e44d3aa41a94 to your computer and use it in GitHub Desktop.
p5js seconds counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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