setup()
setup() runs once when the sketch starts. It's the right place to define fixed colors and text settings that draw() will reuse every frame instead of recalculating them.
function setup(){
createCanvas(windowWidth,windowHeight);
warmCup=color(200,150,90);
coolCup=color(130,110,100);
textAlign(CENTER,CENTER);textSize(24);
}
Line-by-line explanation (4 lines)
createCanvas(windowWidth,windowHeight);- Creates a canvas that fills the entire browser window, so the coffee cup scene stretches to fit any screen size.
warmCup=color(200,150,90);- Stores a warm tan-brown color to represent the cup when the coffee is hot - used later as the starting color for blending.
coolCup=color(130,110,100);- Stores a cooler, grayer color to represent the cup once the coffee has cooled - this is the color the cup blends toward.
textAlign(CENTER,CENTER);textSize(24);- Sets all future text to be centered on its x/y position and to render at 24 pixels tall, so the temperature readout sits neatly in place.