欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS Canvas定時器模擬動態(tài)加載動畫

 更新時間:2016年09月17日 14:07:52   作者:li_han  
這篇文章主要為大家詳細介紹了JS Canvas定時器模擬動態(tài)加載動畫,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Canvas定時器動態(tài)加載動畫,供大家參考,具體內(nèi)容如下

<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title></title>
  <style>

  </style>
</head>
<body>
  <canvas id="canvas" width="500" height="500">你的瀏覽器不支持canvas技術(shù)</canvas>
  <script>
    var c=document.getElementById('canvas');
    var ctx= c.getContext('2d');
    ctx.translate(c.width/2, c.height/2);
    //首先繪制8個靜態(tài)環(huán)繞的圓形
    function create() {
      for (var i = 1; i < 9; i++) {
        if (i==1) {
          ctx.beginPath();
          ctx.arc(0, -30, 5, 0, 2 * Math.PI);
          ctx.fillStyle='#f0f';
          ctx.fill();
        }else{
          ctx.beginPath();
          ctx.arc(0, -30, 5, 0, 2 * Math.PI);
          ctx.strokeStyle ='#000';
          ctx.stroke();
        }
        ctx.rotate(Math.PI * 45 / 180);
      }
    }
    //定時轉(zhuǎn)動
    setInterval(function(){
      ctx.clearRect(-c.width/2,-c.height, c.width, c.height);
      create();
      ctx.rotate(Math.PI*45/180);
    },300);
    //定時關(guān)閉加載
    setTimeout(function(){
     c.style.display='none';
   },12200);
    //
  </script>
</body>
</html>

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論