<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      點擊放煙花效果,隨便玩玩

      HTML

      <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>炫酷煙花效果</title>
          <style>
              body {
                  margin: 0;
                  overflow: hidden;
                  background: radial-gradient(circle at center, #000033, #000);
              }
              canvas {
                  display: block;
              }
          </style>
      </head>
      <body>
          <canvas id="fireworksCanvas"></canvas>
          <script src="fireworks.js"></script>
      </body>
      </html>

       

      JS

      const canvas = document.getElementById('fireworksCanvas');
      const ctx = canvas.getContext('2d');
      
      canvas.width = window.innerWidth;
      canvas.height = window.innerHeight;
      
      window.addEventListener('resize', () => {
          canvas.width = window.innerWidth;
          canvas.height = window.innerHeight;
      });
      
      const fireworks = [];
      const particles = [];
      
      class Firework {
          constructor(x, y, targetX, targetY) {
              this.x = x;
              this.y = y;
              this.targetX = targetX;
              this.targetY = targetY;
              this.speed = 3;
              this.angle = Math.atan2(targetY - y, targetX - x);
              this.distance = Math.hypot(targetX - x, targetY - y);
              this.trail = [];
              this.trailLength = 8;
              this.done = false;
          }
      
          update() {
              const moveX = Math.cos(this.angle) * this.speed;
              const moveY = Math.sin(this.angle) * this.speed;
      
              this.trail.push({ x: this.x, y: this.y });
              if (this.trail.length > this.trailLength) {
                  this.trail.shift();
              }
      
              this.x += moveX;
              this.y += moveY;
      
              if (Math.hypot(this.targetX - this.x, this.targetY - this.y) <= this.speed) {
                  this.done = true;
                  explode(this.targetX, this.targetY);
              }
          }
      
          draw() {
              ctx.beginPath();
              ctx.moveTo(this.trail[0]?.x || this.x, this.trail[0]?.y || this.y);
              this.trail.forEach(point => ctx.lineTo(point.x, point.y));
              ctx.strokeStyle = 'rgba(255, 255, 255, 0.6)';
              ctx.lineWidth = 2;
              ctx.stroke();
      
              ctx.beginPath();
              ctx.arc(this.x, this.y, 3, 0, Math.PI * 2);
              ctx.fillStyle = 'white';
              ctx.fill();
          }
      }
      
      class Particle {
          constructor(x, y, color) {
              this.x = x;
              this.y = y;
              this.size = Math.random() * 2 + 1;
              this.speedX = Math.random() * 5 - 2.5;
              this.speedY = Math.random() * 5 - 2.5;
              this.gravity = 0.05;
              this.friction = 0.98;
              this.alpha = 1;
              this.decay = Math.random() * 0.02 + 0.01;
              this.color = color;
          }
      
          update() {
              this.speedX *= this.friction;
              this.speedY *= this.friction;
              this.speedY += this.gravity;
              this.x += this.speedX;
              this.y += this.speedY;
              this.alpha -= this.decay;
      
              if (this.alpha <= 0) {
                  this.alpha = 0;
              }
          }
      
          draw() {
              ctx.save();
              ctx.globalAlpha = this.alpha;
              ctx.beginPath();
              ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
              ctx.fillStyle = this.color;
              ctx.fill();
              ctx.restore();
          }
      }
      
      function explode(x, y) {
          const colors = ['#FF1461', '#18FF92', '#5A87FF', '#FBF38C', '#FF61A6'];
          const particleCount = 150;
      
          for (let i = 0; i < particleCount; i++) {
              const color = colors[Math.floor(Math.random() * colors.length)];
              particles.push(new Particle(x, y, color));
          }
      }
      
      function animate() {
          ctx.fillStyle = 'rgba(0, 0, 0, 0.15)';
          ctx.fillRect(0, 0, canvas.width, canvas.height);
      
          fireworks.forEach((firework, index) => {
              firework.update();
              firework.draw();
      
              if (firework.done) {
                  fireworks.splice(index, 1);
              }
          });
      
          particles.forEach((particle, index) => {
              particle.update();
              particle.draw();
      
              if (particle.alpha === 0) {
                  particles.splice(index, 1);
              }
          });
      
          requestAnimationFrame(animate);
      }
      
      canvas.addEventListener('click', (e) => {
          const x = canvas.width / 2;
          const y = canvas.height;
          const targetX = e.clientX;
          const targetY = e.clientY;
          fireworks.push(new Firework(x, y, targetX, targetY));
      });
      
      animate();

       

      使用 CSS 漸變背景

      煙花尾跡:通過 trail 數組記錄煙花移動的歷史位置,繪制出漸隱的尾跡效果。

       

       

      posted @ 2024-08-20 21:20  最小生成樹  閱讀(101)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产一区二区不卡91| 伊人久久大香线蕉综合5g| 欧美三级中文字幕在线观看| 免费吃奶摸下激烈视频| 男人猛躁进女人免费播放| 精品日韩亚洲AV无码| 亚洲熟少妇一区二区三区| 伦伦影院精品一区| 国产日韩av二区三区| 青青草原网站在线观看| 日韩中文字幕综合第二页| 94人妻少妇偷人精品| 国产精品自拍午夜福利| 亚洲精品色无码AV试看| 在线播放无码后入内射少妇| 国产精品第一页一区二区| 大陆精大陆国产国语精品| 国产最大成人亚洲精品| 亚洲日韩国产二区无码| 国产色悠悠在线免费观看| 影视先锋av资源噜噜| 久久精品熟女亚洲av艳妇| 精品亚洲国产成人| 日本系列亚洲系列精品| 久久月本道色综合久久| 激情综合网五月婷婷| 国产激情免费视频在线观看| 激情在线一区二区三区视频 | 波多野结衣久久一区二区| 在线免费播放亚洲自拍网| 亚洲天堂av日韩精品| 亚洲中文字幕国产精品| 国产高清小视频一区二区| 一级做a爰片在线播放| 亚洲av日韩av永久无码电影| 灵山县| 国产精品 第一页第二页| 宝贝腿开大点我添添公口述视频 | 色欲av蜜桃一区二区三| 亚洲天堂一区二区三区四区| 久久99精品久久久久久9|