setup()
setup() runs exactly once when the sketch starts. It's the right place to create the canvas and initialize any variables (like colors) that don't need to change every frame.
function setup(){
createCanvas(windowWidth,windowHeight);
textAlign(CENTER,CENTER);
c1=color(135,206,250);c2=color(180,228,255);
}
Line-by-line explanation (3 lines)
createCanvas(windowWidth,windowHeight);- Creates a canvas that fills the entire browser window, using the browser's current width and height.
textAlign(CENTER,CENTER);- Tells p5.js to center text both horizontally and vertically around the x,y coordinates you give to text(), so each emoji is drawn centered on its position instead of offset.
c1=color(135,206,250);c2=color(180,228,255);- Defines two light sky-blue colors that will later be blended together to paint the gradient background.