模仿支付宝刮刮卡效果

模仿支付宝刮刮卡效果

 <!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta name='description' content='this is my page'>
<meta name='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel='stylesheet' type='text/css' href='./css/index.css' />
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type='text/css'>
html,body,canvas {
margin: 0; padding: 0;
} html {
height: 100%;
} body {
background: #000;
} #can {
background: #FFF url('./images/index.jpg') no-repeat center; backgrond-size: cover; display: block;
margin: 25px auto; border-radius: 2px; cursor: pointer;
}
</style>
<script type='text/javascript'>
$( function(){
var can = $( '#can' ).get( 0 );
var oCan = can.getContext( '2d' );
oCan.beginPath();
oCan.fillStyle = '#BBB';
oCan.fillRect( 0 , 0 , can.width , can.height );
oCan.closePath();
can.onmousedown = function(){
this.onmousemove = function( ev ){
var ev = window.event || ev;
var clientX = ev.clientX - can.offsetLeft;
var clientY = ev.clientY - can.offsetTop;
oCan.fillStyle = 'rgba(132,25,65,.3)';
oCan.arc( clientX , clientY , 4 , 0 , 2 * Math.PI , false );
oCan.fill();
oCan.globalCompositeOperation = 'destination-out';
};
this.onmouseup = function(){
this.onmousemove = null;
this.onmouseup = null;
};
};
} );
</script>
</head>
<body>
<canvas id='can' width='300' height='168'>检测到您的浏览器版本过低请升级您的浏览器版本以获取更好的用户体验...</canvas>
</body>
</html>
05-02 22:55