setup()
setup() runs once when the sketch loads. This is where you configure the canvas, set drawing modes, and initialize defaults that apply to the whole sketch.
function setup() {
createCanvas(windowWidth, windowHeight);
textAlign(CENTER, CENTER);
colorMode(HSB, 360, 100, 100, 100); // Hue/Sat/Bright/Alpha
noStroke();
}
Line-by-line explanation (4 lines)
createCanvas(windowWidth, windowHeight);- Creates a canvas as wide and tall as the entire browser window, so the sketch fills the whole screen
textAlign(CENTER, CENTER);- Sets all text to be centered both horizontally and vertically at the x,y coordinates you pass to text()
colorMode(HSB, 360, 100, 100, 100);- Switches from RGB to HSB color mode where 360 is hue (0–360°), 100 is saturation (0–100), brightness (0–100), and alpha (0–100). This makes rainbow cycling easier because you just increment the first number
noStroke();- Disables all outlines around shapes so only filled areas appear—cleaner look for the glowing text