简体   繁体   中英

erase functionality in canvas

I need to erase the contents of my canvas. I can achieve this by using 'globalCompositeOperation = "destination-out"'. I have already stored the draw coordinates in my json object, but after erasing I need to update my json object. I tried to capture it's x,y co-ordinate on mouse move (while erasing). Then I matched the same with my previous store object and updated the same. But it's quite a big procedure which causes degradation in my performance. Is there any other way to do it?

This will clear all contents of your canvas. (Assuming that ctx is your context, and width and height are the width and height of your canvas.

ctx.clearRect(0, 0, width, height)

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