“Erasing” in html5 canvas

If you want to draw a black transparent stroke, you probably want:

context.globalCompositeOperation = "destination-out";
context.strokeStyle = "rgba(0,0,0,1)";

Remember to save the previous globalCompositeOperation and then restore it later or transparency won’t work properly!

Leave a Comment