# Canvas Scratch card **Repository Path**: smilestone/Canvas-Scratch-card ## Basic Information - **Project Name**: Canvas Scratch card - **Description**: 支持移动手机的HTML5 canvas刮刮卡插件 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2017-07-14 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #Canvas Scratch Card 支持移动手机的HTML5 canvas刮刮卡插件 ### 插件介绍 ScratchCard是一款支持移动手机的HTML5 canvas刮刮卡插件。该刮刮卡插件支持移动触摸事件,提供刮卡的回调函数,简单易用,效果非常不错。 ### demo演示地址[注意canvas要在服务器下运行](http://www.htmleaf.com/Demo/201610064071.html) 兼容性 IE10+ ### 使用方法 在页面中引入Scratch.js文件。 ``` ``` ### HTML结构 ```
``` ### CSS样式 ``` /* Scratch */ .scratch_container { position: relative; margin: 0 auto; max-width: 1024px; } /* 刮刮可以涂抹的视口,请保持与背景,canvas一致*/ .scratch_viewport { position: relative; max-width: 200px; max-height:200px; margin: 0 auto; z-index: 0; } /* 刮开后的图片 */ .scratch_picture-under { position: absolute; top: 0; left: 0; width: 100%; display: block; z-index: -1; } /* canvas */ .scratch_container canvas { position: relative; width: 100%; height: auto; z-index: 1; } ``` ### 初始化插件 在页面页面底部标记结束之前,使用下面的代码来实例化一个刮刮卡对象。 ``` ``` ### 配置参数 - canvasId:canvas的id。 - imageBackground:背景图片(刮开后呈现的图片)。 - pictureOver:前景图片。 - sceneWidth:canvas的宽度。 - sceneHeight:canvas的高度。 - radius:清除区域的半径。 - nPoints:清除区域的杂点数量。 - percent:在清除多少区域之后清空canvas。 - cursor:光标。 - png:png格式的光标。 - x:Move position x。 - y:Move position y。 - cur:cur格式的光标(IE使用)。