刮刮乐刮到多少百分比才能显示全部内容呢?
- 内容介绍
- 文章标签
- 相关推荐
本文共计233个文字,预计阅读时间需要1分钟。
原理:使用 ctx.globalCompositeOperation=destination-out; 在源图像外显示目标图像。只有源图像外的目标图像部分会被显示,源图像本身是透明的。
代码:javascriptfunction tapClip() { var hastouch=true;}
原理:ctx.globalCompositeOperation = "destination-out"; 在源图像外显示目标图像。只有源图像外的目标图像部分会被显示,源图像是透明的。//在小画板上画画的函数 function tapClip(){ var hastouch = "ontouchstart" in window ? true:false, tapstart = hastouch ? "touchstart":"mousedown", tapmove = hastouch ? "touchmove":"mousemove", tapend = hastouch ? "touchend":"mouseup"; ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.lineWidth = a; //在源图像外显示目标图像。只有源图像外的目标图像部分会被显示,源图像是透明的。 ctx.globalCompositeOperation = "destination-out"; //touchstart或mousedown canvas.addEventListener(tapstart , function(e){ e.preventDefault(); ctx.beginPath(); //touchmove或mousemove canvas.addEventListener(tapmove , tapmoveHandler); canvas.addEventListener(tapend , function(){ canvas.removeEventListener(tapmove , tapmoveHandler); //获取像素 var data = ctx.getImageData(0,0,w,h).data; for (var i=0,j=0;i
本文共计233个文字,预计阅读时间需要1分钟。
原理:使用 ctx.globalCompositeOperation=destination-out; 在源图像外显示目标图像。只有源图像外的目标图像部分会被显示,源图像本身是透明的。
代码:javascriptfunction tapClip() { var hastouch=true;}
原理:ctx.globalCompositeOperation = "destination-out"; 在源图像外显示目标图像。只有源图像外的目标图像部分会被显示,源图像是透明的。//在小画板上画画的函数 function tapClip(){ var hastouch = "ontouchstart" in window ? true:false, tapstart = hastouch ? "touchstart":"mousedown", tapmove = hastouch ? "touchmove":"mousemove", tapend = hastouch ? "touchend":"mouseup"; ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.lineWidth = a; //在源图像外显示目标图像。只有源图像外的目标图像部分会被显示,源图像是透明的。 ctx.globalCompositeOperation = "destination-out"; //touchstart或mousedown canvas.addEventListener(tapstart , function(e){ e.preventDefault(); ctx.beginPath(); //touchmove或mousemove canvas.addEventListener(tapmove , tapmoveHandler); canvas.addEventListener(tapend , function(){ canvas.removeEventListener(tapmove , tapmoveHandler); //获取像素 var data = ctx.getImageData(0,0,w,h).data; for (var i=0,j=0;i

