zoukankan      html  css  js  c++  java
  • h5-日食效果

      1 <!DOCTYPE html>
      2 <html lang="en">
      3 <head>
      4     <meta charset="UTF-8">
      5     <title>Title</title>
      6     <style>
      7         *
      8         {
      9             margin: 0;
     10             padding: 0;
     11         }
     12         #box
     13         {
     14             width: 1000px;
     15             height: 600px;
     16             margin: 50px auto;
     17             position: relative;
     18         }
     19         #can
     20         {
     21             background: #000;
     22         }
     23         #bt1,#bt2
     24         {
     25             background: #000;
     26             color: #fff;
     27             font-size: 25px;
     28             position: fixed;
     29             left:40px;
     30             border: none;
     31         }
     32         #bt1
     33         {
     34             top: 230px;
     35         }
     36         #bt2
     37         {
     38             top: 300px;
     39         }
     40         #mode
     41         {
     42             width: 200px;
     43             height: 200px;
     44             background: #000;
     45             position: absolute;
     46             -webkit-border-radius:50%;
     47             -moz-border-radius:50%;
     48             border-radius:50%;
     49             left: 620px;
     50             top: 195px;
     51         }
     52     </style>
     53 </head>
     54 <body>
     55     <div id="box">
     56         <canvas width="1000" height="600" id="can"></canvas>
     57         <div id="mode"></div>
     58     </div>
     59     <button id="bt1">start</button>
     60     <button id="bt2">stop</button>
     61 <script >
     62     var bt1=document.getElementById('bt1');
     63     var bt2=document.getElementById('bt2');
     64     var mode=document.getElementById('mode');
     65     var can=document.getElementById('can');
     66     var ctx=can.getContext('2d');
     67     var time1=null;
     68     //白色
     69     ctx.beginPath();
     70     ctx.moveTo(200,200);
     71     ctx.arc(500,220,100,0,360,false);
     72     ctx.fillStyle='#fff';
     73     ctx.shadowBlur=50;
     74     ctx.shadowColor='yellow';
     75     ctx.fill();
     76     ctx.closePath();
     77     //黑色
     78     var x=620,y=195;
     79     var a=true,b=true;
     80     bt1.onclick=function () {
     81         clearInterval(time1);
     82         time1=setInterval(function () {
     83             console.log(x);
     84             //x轴方向
     85             if(a){
     86                 x-=3;
     87                 if (x<=168){
     88                     x=168;
     89                     a=false;
     90                 }
     91                 mode.style.left=x+"px";
     92             }else{
     93                 x+=2;
     94                 if(x>=620){
     95                     x=620;
     96                     a=true;
     97                 }
     98                 mode.style.left=x+"px";
     99             }
    100             //y轴方向
    101             if(b){
    102                 y--;
    103                 if(y<=45){
    104                     y=250;
    105                     b=false;
    106                 }
    107                 mode.style.top=y+"px";
    108             }else {
    109                 y++;
    110                 if(y>=195)
    111                 {
    112                     y=195;
    113                     b=true;
    114                 }
    115                 mode.style.top=y+"px";
    116             }
    117         },100)
    118     };
    119     bt2.onclick=function () {
    120         clearInterval(time1);
    121     }
    122 </script>
    123 </body>
    124 </html>

  • 相关阅读:
    C# IP地址与数字之间的互转
    C# 获取本机的所有ip地址,并过滤内网ip
    C# POST数据base64到接口会出错的问题
    C# 使用 Task 替换 ThreadPool ,异步监测所有线程(任务)是否全部执行完毕
    C# 线程池执行操作例子
    输入及词法分析详解
    用java实现编译器-算术表达式及其语法解析器的实现
    用java实现一个简易编译器-语法解析
    用java实现一个简易编译器1-词法解析入门
    模板方法模式
  • 原文地址:https://www.cnblogs.com/yoyoyoyoyoyo/p/5997586.html
Copyright © 2011-2022 走看看