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.
Thanx.
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.
Thanx.
set the pencil color to transparent:
context.fillStyle = "rgba(255,0,0,0)";
in rgba()
format, the last one is the alpha channel, 0 is totally transparent
As an alternative, you can use multiple <canvas>
objects drawn over each other, then erase from the top canvas to reveal the image beneath. See: html5 - canvas element - Multiple layers
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.
The question is answered in a bit more detail here:
http://stackoverflow.com/questions/3328906/erasing-in-html5-canvas