1 <script> 2 window.onload=function(){ 3 var canvas=document.querySelector(‘canvas‘) 4 canvas.width=document.documentElement.clientWidth; (canvas.getContext){ 7 var ctx=canvas.getContext(‘2d‘) img=new Image(); 10 img.src="img/cover.jpg"; 11 img.onload=function(){ 12 drap(ctx,img) 13 } 14 } 15 function drap(ctx,img){ 16 ctx.drawImage(img,0,0,canvas.width,canvas.height) touaddEventListener(‘touchstart‘) 19 touaddEventListener(‘touchmove‘) 20 } 21 function touaddEventListener(el){ 22 canvas.addEventListener(el,function(e){ 23 var ev=e||event touchC=ev.changedTouches[0] 26 var x=touchC.clientX; 27 var y=touchC.clientY; 28 ctx.save() 29 ctx.beginPath() 30 ctx.globalCompositeOperation=‘destination-out‘ 31 ctx.arc(x,y,20,0,360*Math.PI/180) 32 ctx.fill() 33 ctx.restore() 34 }) 35 } 36 37 } 38 39 </script>