I’m working on a html5 app for the ipad. I would like to display an image in the canvas element with a background image underneath. When the user wipes their finger over the image in the canvas it should erase to reveal the background image. Here is the code I am starting with. Right now I am just trying to draw a transparent line to reveal the background image. I will worry about the touch events later. Any ideas?
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
var img = new Image();
img.src = 'Lord-of-Bones.png';
img.onload = function(){
ctx.drawImage(img,0,0);
ctx.globalCompositeOperation = "copy";
ctx.strokeStyle = "rgba(0,0,0,0)";
ctx.beginPath();
ctx.moveTo(30,96);
ctx.lineTo(70,66);
ctx.lineTo(103,76);
ctx.lineTo(170,15);
ctx.stroke();
}
}
This is what ended up working for me.