简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM