zoukankan      html  css  js  c++  java
  • [ html canvas 模仿支付宝刮刮卡效果 ] canvas绘图属性 模仿支付宝刮刮卡效果实例演示

     1 <!DOCTYPE html>
     2 <html lang='zh-cn'>
     3 <head>
     4 <title>Insert you title</title>
     5 <meta name='description' content='this is my page'>
     6 <meta name='keywords' content='keyword1,keyword2,keyword3'>
     7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     8 <link rel='stylesheet' type='text/css' href='./css/index.css' />
     9 <script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
    10 <style type='text/css'>
    11 html,body,canvas {
    12     margin: 0; padding: 0;
    13 }
    14 
    15 html {
    16     height: 100%;
    17 }
    18 
    19 body {
    20     background: #000;
    21 }
    22 
    23 #can {
    24     background: #FFF url('./images/index.jpg') no-repeat center; backgrond-size: cover; display: block;
    25     margin: 25px auto; border-radius: 2px; cursor: pointer;
    26 }
    27 </style>
    28 <script type='text/javascript'>
    29     $( function(){
    30         var can = $( '#can' ).get( 0 );
    31         var oCan = can.getContext( '2d' );
    32         oCan.beginPath();
    33         oCan.fillStyle = '#BBB';
    34         oCan.fillRect( 0 , 0 , can.width , can.height );
    35         oCan.closePath();
    36         can.onmousedown = function(){
    37             this.onmousemove = function( ev ){
    38                 var ev = window.event || ev;
    39                 var clientX = ev.clientX - can.offsetLeft;
    40                 var clientY = ev.clientY - can.offsetTop;
    41                 oCan.fillStyle = 'rgba(132,25,65,.3)';
    42                 oCan.arc( clientX , clientY , 4 , 0 , 2 * Math.PI , false );
    43                 oCan.fill();
    44                 oCan.globalCompositeOperation = 'destination-out';
    45             };
    46             this.onmouseup = function(){
    47                 this.onmousemove = null;
    48                 this.onmouseup = null;
    49             };
    50         };
    51     } );
    52 </script>
    53 </head>
    54 <body>
    55     <canvas id='can' width='300' height='168'>检测到您的浏览器版本过低请升级您的浏览器版本以获取更好的用户体验...</canvas>
    56 </body>
    57 </html>
  • 相关阅读:
    python argparse sys.argv
    python __all__
    一些方便系统诊断的bash函数
    yarn集群客户端gateway常用限制
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun
    Hadoop fs -put bandwidth 暴力版
    PYTHON SOCKET编程简介
    java实现点选汉字验证码(转)
    springboot配置log4j
    vue文字跑马灯效果
  • 原文地址:https://www.cnblogs.com/mysearchblog/p/5948592.html
Copyright © 2011-2022 走看看