setup()
setup() runs once when the sketch starts. It's the right place to size the canvas and initialize any starting data, like the color palette used throughout the sketch.
function setup(){
createCanvas(windowWidth,windowHeight);
cols=['#ff4b5c','#ffd93d','#4cd137','#00a8ff','#9b59b6'];
background(3,5,15);
}
Line-by-line explanation (3 lines)
createCanvas(windowWidth,windowHeight);- Makes the canvas fill the entire browser window so fireworks can launch from anywhere on screen.
cols=['#ff4b5c','#ffd93d','#4cd137','#00a8ff','#9b59b6'];- Defines five hex color strings that will be picked randomly for each firework's color.
background(3,5,15);- Paints the canvas a very dark navy/black once, creating the night sky before any fireworks appear.