canvas clearrect code example
Example 1: Javascript clear canvas
var canvas = document.getElementById("myCanvasID");
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height); //clear html5 canvas
Example 2: js clearect
ctx.clearRect(x, y, width, height);