Clearing the Canvas with JavaScript
To clear the entire canvas ctx.clearRect(0, 0, canvas.width, canvas.height); Explanation: clearRect(x, y, width, height) clears the specified rectangular area and sets it to transparent black. To clear the entire canvas, you can use the clearRect() method of the canvas’s 2D rendering context. This method clears the specified rectangular area, making it fully transparent. To clear … Read more