茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    javascript實現(xiàn)起伏的水波背景效果
    來源:易賢網(wǎng) 閱讀:2065 次 日期:2016-06-29 15:19:20
    溫馨提示:易賢網(wǎng)小編為您整理了“javascript實現(xiàn)起伏的水波背景效果”,方便廣大網(wǎng)友查閱!

    這篇文章主要為大家詳細(xì)介紹了javascript實現(xiàn)起伏的水波背景效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下

    本文實例為大家分享了js水波背景效果的實現(xiàn)代碼,供大家參考,具體內(nèi)容如下

    效果圖:

    名單

    實現(xiàn)代碼:

    代碼如下:

    <!DOCTYPE html>

    <html>

    <head>

     <title>水波背景</title>

     <meta charset="gb2312" />

     <style>

     html, body {width:100%; height:100%; padding:0; margin:0;}

     </style>

    </head>

    <body>

     <canvas id="canvas" style="position:absolute;top:0px;left:0px;z-index:1;"></canvas>

     <script type="text/javascript">

      var canvas = document.getElementById('canvas'); 

      var ctx = canvas.getContext('2d'); 

      canvas.width = canvas.parentNode.offsetWidth; 

      canvas.height = canvas.parentNode.offsetHeight;

      //如果瀏覽器支持requestAnimFrame則使用requestAnimFrame否則使用setTimeout 

      window.requestAnimFrame = (function(){ 

      return window.requestAnimationFrame  || 

        window.webkitRequestAnimationFrame || 

        window.mozRequestAnimationFrame || 

        function( callback ){ 

         window.setTimeout(callback, 1000 / 60); 

        }; 

      })(); 

      // 波浪大小

      var boHeight = canvas.height / 10;

      var posHeight = canvas.height / 1.2;

      //初始角度為0 

      var step = 0; 

      //定義三條不同波浪的顏色 

      var lines = ["rgba(0,222,255, 0.2)", 

          "rgba(157,192,249, 0.2)", 

          "rgba(0,168,255, 0.2)"]; 

      function loop(){ 

       ctx.clearRect(0,0,canvas.width,canvas.height); 

       step++; 

       //畫3個不同顏色的矩形 

       for(var j = lines.length - 1; j >= 0; j--) { 

        ctx.fillStyle = lines[j]; 

        //每個矩形的角度都不同,每個之間相差45度 

        var angle = (step+j*50)*Math.PI/180; 

        var deltaHeight = Math.sin(angle) * boHeight;

        var deltaHeightRight = Math.cos(angle) * boHeight; 

        ctx.beginPath();

        ctx.moveTo(0, posHeight+deltaHeight); 

        ctx.bezierCurveTo(canvas.width/2, posHeight+deltaHeight-boHeight, canvas.width / 2, posHeight+deltaHeightRight-boHeight, canvas.width, posHeight+deltaHeightRight); 

        ctx.lineTo(canvas.width, canvas.height); 

        ctx.lineTo(0, canvas.height); 

        ctx.lineTo(0, posHeight+deltaHeight); 

        ctx.closePath(); 

        ctx.fill(); 

       }

       requestAnimFrame(loop);

      } 

      loop(); 

     </script>

    </body>

    </html>

    以上就是本文的全部內(nèi)容,希望對大家學(xué)習(xí)javascript程序設(shè)計有所幫助。

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:javascript實現(xiàn)起伏的水波背景效果
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報班

    • 報班類型
    • 姓名
    • 手機(jī)號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)