setup()
setup() runs exactly once when the sketch starts, which makes it the right place to size the canvas and set up variables that don't change every frame, like colors and text settings.
function setup(){createCanvas(windowWidth,windowHeight);textAlign(CENTER,CENTER);textWrap(WORD);
cookieCol=color(240,194,125);shadowCol=color(205,150,80);bgCol=color(40,0,0);}
Line-by-line explanation (6 lines)
createCanvas(windowWidth,windowHeight)- Makes the canvas fill the entire browser window so the sketch looks fullscreen.
textAlign(CENTER,CENTER)- Sets all future text to be centered both horizontally and vertically around the coordinates you give text().
textWrap(WORD)- Makes long fortune strings wrap onto multiple lines at word boundaries instead of overflowing.
cookieCol=color(240,194,125)- Stores a warm tan color used for the top layer of the cookie.
shadowCol=color(205,150,80)- Stores a slightly darker tan used to fake shading behind each cookie half.
bgCol=color(40,0,0)- Stores a dark red background color that gets drawn fresh every frame.