setup()
setup() runs once when the sketch starts. Here we initialize the canvas size and configure text settings that will be used throughout the sketch.
function setup() {
createCanvas(windowWidth, windowHeight);
textAlign(CENTER, CENTER);
textFont('monospace');
}
Line by Line:
createCanvas(windowWidth, windowHeight)- Creates a canvas that fills the entire browser window, making the stopwatch responsive to screen size
textAlign(CENTER, CENTER)- Centers all text both horizontally and vertically, so text appears exactly where you specify
textFont('monospace')- Sets the font to monospace (fixed-width), which makes the digital display look like a classic timer