setup()
setup() runs exactly once, right when the sketch starts. It's the perfect place to record a starting timestamp (like startTime) that later code can compare against millis() to measure elapsed time.
function setup() {
createCanvas(windowWidth, windowHeight);
startTime = millis();
textAlign(CENTER, TOP);
textSize(24);
}
Line-by-line explanation (4 lines)
createCanvas(windowWidth, windowHeight);- Creates a canvas that fills the entire browser window, so the plant scene stretches to whatever screen size the viewer has.
startTime = millis();- Records the exact moment (in milliseconds since the page loaded) that the sketch started - this is the reference point used later to measure how much time has passed.
textAlign(CENTER, TOP);- Configures future text() calls to be centered horizontally and aligned from the top, so the stage label sits neatly at the top-center of the screen.
textSize(24);- Sets the font size used for the stage label text drawn every frame.