粒子特效页面

<!DOCTYPE html>
<html>
<head>
  <title>粒子特效页面</title>
  <style>
    body {
      margin: 0;
      overflow: hidden;
    }
    canvas {
	background-color: #02051a;
      display: block;
    }
  </style>
</head>
<body>
  <canvas id="myCanvas"></canvas>

  <script>
    const canvas = document.getElementById("myCanvas");
    const ctx = canvas.getContext("2d");
    const width = window.innerWidth;
    const height = window.innerHeight;

    canvas.width = width;
    canvas.height = height;

    const particles = [];
    const connections = [];
    const particleCount = 300;
    const particleSpeed = 1;
    const particleSize = 2;
    const maxDistance = 100;
    const lightningColor = "#fff";

    class Particle {
      constructor() {
        this.x = Math.random() * width;
        this.y = Math.random() * height;
        this.color = "#fff";
        this.angle = Math.random() * 360;
        this.speed = Math.random() * particleSpeed;
        this.opacity = Math.random() * 0.5 + 0.5;
      }

      update() {
        this.x += Math.cos(this.angle) * this.speed;
        this.y += Math.sin(this.angle) * this.speed;

        if (this.x < 0 || this.x > width || this.y < 0 || this.y > height) {
          this.x = Math.random() * width;
          this.y = Math.random() * height;
        }
      }

      draw() {
        ctx.beginPath();
        ctx.arc(this.x, this.y, particleSize, 0, Math.PI * 2);
        ctx.fillStyle = `rgba(255, 255, 255, ${this.opacity})`;
        ctx.fill();
      }
    }

    function createParticles() {
      for (let i = 0; i < particleCount; i++) {
        particles.push(new Particle());
      }
    }

    function drawConnections() {
      for (let i = 0; i < particles.length; i++) {
        for (let j = i + 1; j < particles.length; j++) {
          const dx = particles[i].x - particles[j].x;
          const dy = particles[i].y - particles[j].y;
          const distance = Math.sqrt(dx * dx + dy * dy);

          if (distance < maxDistance) {
            ctx.beginPath();
            ctx.moveTo(particles[i].x, particles[i].y);
            ctx.lineTo(particles[j].x, particles[j].y);
            ctx.strokeStyle = lightningColor;
            ctx.lineWidth = 0.2 * (1 - distance / maxDistance);
            ctx.stroke();
            ctx.closePath();
          }
        }
      }
    }

    function animate() {
      ctx.clearRect(0, 0, width, height);

      for (const particle of particles) {
        particle.update();
        particle.draw();
      }

      drawConnections();

      requestAnimationFrame(animate);
    }

    document.addEventListener("mousemove", (e) => {
      const mouseX = e.clientX;
      const mouseY = e.clientY;

      for (const particle of particles) {
        const dx = mouseX - particle.x;
        const dy = mouseY - particle.y;
        const distance = Math.sqrt(dx * dx + dy * dy);

        if (distance < maxDistance) {
          particle.angle = Math.atan2(dy, dx);
          particle.speed = 5;
        } else {
          particle.speed = Math.random() * particleSpeed;
        }
      }
    });

    createParticles();
    animate();
  </script>
</body>
</html>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
明日方舟官网粒子特效是指在明日方舟官方网站上使用的一种特效效果,用于增强网站的视觉吸引力和用户体验。这些粒子特效通常以动态的、流动的、闪烁的方式展现,可以呈现出各种形状、颜色和运动效果。 具体来说,明日方舟官网粒子特效可能包括以下几个方面的设计和实现: 1. 粒子系统:通过使用粒子系统技术,可以在网页上生成大量的小粒子,并对其进行控制和调整。这些小粒子可以具有不同的形状、大小、颜色和运动轨迹,从而形成各种炫酷的特效效果。 2. 动画效果:通过对粒子的位置、透明度、旋转等属性进行动态变化,可以实现流动、闪烁、爆炸等各种动画效果。这些动画效果可以使网页更加生动有趣,吸引用户的注意力。 3. 交互效果:在用户与网页进行交互时,可以通过触发特定事件来改变粒子的行为。例如,当用户鼠标悬停在某个区域时,粒子可以聚集或散开;当用户点击某个按钮时,粒子可以爆炸或消失等等。 4. 背景效果:粒子特效还可以用作网页的背景效果,为整个页面增添动感和层次感。通过调整粒子的密度、速度和颜色等参数,可以创建出各种炫丽的背景效果,使网页更加引人注目。 总的来说,明日方舟官网粒子特效通过使用粒子系统、动画效果、交互效果和背景效果等技术手段,为官网带来了更加生动、炫酷的视觉效果,提升了用户的浏览体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值