You can use the clearRect method to clear any rectangular section of the canvas.
// Clear the entire canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
Note: clearRect is dependent on the transformation matrix.
To deal with this, it's possible to reset the transformation matrix befor...