setup()
setup() runs once when the sketch starts. It configures the canvas size and text/shape drawing modes that will be used throughout the sketch. Using windowWidth and windowHeight makes the sketch responsive to different screen sizes.
function setup(){
createCanvas(windowWidth,windowHeight);
textAlign(CENTER,CENTER);
textSize(32);
rectMode(CENTER);
}
Line by Line:
createCanvas(windowWidth,windowHeight)- Creates a canvas that fills the entire browser window, making the sketch responsive to window size
textAlign(CENTER,CENTER)- Centers all text both horizontally and vertically around the coordinates where text is drawn
textSize(32)- Sets the font size to 32 pixels for all text drawn after this point
rectMode(CENTER)- Changes rectangle drawing mode so coordinates represent the center point instead of the top-left corner