本文介绍了HTML5 Canvas橡皮擦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一种方法来实现橡皮擦(除了使用白色铅笔吗?)。
There's a way of implementing an eraser (other than using a white pencil?).
我使用分层,我在画布下有一个图像,所以,如果橡皮擦是白色的,用户会注意到,因为下面的图像不是固体白色。
I'm using layering, I have an image below the canvas, so, if eraser paints white, the user is going to notice since the below image isn't solid white.
推荐答案
基本上,将 globalCompositeOperation
设置为 copy
并使用不透明度为零的颜色绘制,例如rgba(0,0,0,0)
。
Basically, set the globalCompositeOperation
to copy
and paint using a color with opacity zero, e.g. "rgba(0,0,0,0)"
as you were trying.
这里有更详细的说明:
这篇关于HTML5 Canvas橡皮擦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!