Rather than use clearRect which makes all pixels transparent you may want a background.
To clear with a gradient
// create the background gradient once
var bgGrad = ctx.createLinearGradient(0,0,0,canvas.height);
bgGrad.addColorStop(0,"#0FF");
bgGrad.addColorStop(1,"#08F");
...