var canvas = document.querySelector('canvas'); var ctx = canvas.getContext('2d'); //ctx.clearRect(x, y, width, height); ctx.clearRect(20, 20, 100, 50);