background() must be the first call in p5.js draw() to clear each frame; placing it after shapes wipes them
p5.js draw() paints over the previous state on every frame. background() fills the entire canvas, erasing everything drawn so far. If absent from draw(), shapes from every frame accumulate (the trails/blob bug). If it appears after shape-drawing calls, it covers them entirely, producing an apparently blank frame. Placing background(0) as the very first call in draw() is the canonical clear-then-draw pattern. For intentional motion blur or trails, background(0, 20) (semi-transparent) is the alternative.
Examples
Correct: function draw(){ background(0); ellipse(mouseX, mouseY, 40, 40); }. Wrong: function draw(){ ellipse(mouseX, mouseY, 40, 40); background(0); } — the ellipse is never seen.
Assessment
A student’s sketch shows all shapes ever drawn layered on top of each other. Identify the missing call, where to place it, and what to use instead for a ghosting/trail effect.