简体   繁体   中英

How to clear part of the canvas using strokeStyle?

My problem is following:

I have an and it does have transparent background. It is used as drawing board over other elements. Once something is drawn, I would like to be able to erase it using eraser tool, which will have kind of same functionality as drawing tool.

One option is using clearRect and cleaning small rect on dragging. Is there any more brilliant solution? Perhaps something simple what involves strokeStyle?

Try drawing with the context property "globalCompositeOperation" set to "destination-out". Does that work with all browsers which support Canvas?

如果对于您的橡皮擦工具,将strokeStyle设置为rgba(255,255,255,0),从而用透明的白色填充笔触中涉及的所有画布像素,从而本质上“清除”它们,该怎么办?

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