'How to clear specific line in canvas using Javascript?

I'm looking for a way to delete a specific line without clearing and redrawing it. How to clear specific line in Canvas : HTML5 I saw this question but everyone said you must clear all the page and redraw. but is there a better way without drawing and clearing?



Solution 1:[1]

There is definitely a way! Try entering the coordinates of the sentences x and y and its width and height. This way you can clear only a portion of canvas. ctx.clearRect() actually clears a rectangle on the canvas and is used to clear the whole canvas by giving it 0 as the x, 0 as the y and giving it the width and height of canvas.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 G Jeswin