setup()
setup() runs exactly once when the sketch starts. It's the right place to configure the canvas and any global drawing defaults like font and text size before draw() begins looping.
function setup() {
createCanvas(windowWidth, windowHeight);
textFont("sans-serif"); textSize(16);
}
Line-by-line explanation (3 lines)
createCanvas(windowWidth, windowHeight);- Creates a canvas that fills the entire browser window, so the sketch is always full-screen.
textFont("sans-serif");- Sets the default font used by every text() call afterward.
textSize(16);- Sets the default font size in pixels for all text drawn in the sketch.