canvas实现泡泡汇聚粒子动画效果代码

代码语言:html

所属分类:粒子

代码描述:canvas实现泡泡汇聚粒子动画效果代码

代码标签: canvas 泡泡 汇聚 粒子 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  


  
  
<style>
html, body {
            height: 100%;
        }

        body { 
            margin: 0;
        }

        #canvas {
            width: 100%;
            height: 100%;
            background: #000000;
            position: relative;
            display: grid;
        }

        .bubble {
            grid-column: 1;
            grid-row: 1;
            background: white;
            width: 2em;
            aspect-ratio: 1;
            border-radius: 999em;
            align-self: center;
            justify-self: center;
        }
</style>

  
  
  
</head>

<body translate="no">
  <div id="canvas"></div>
  
      <script >
(function () {

  const $canvas = document.getElementById('canvas');

  if (!$canvas) {
    return;
  }

  let angle = 0;

  window.addEventListener('mousemove', function (event) {
    const offsetX = event.pageX - window.innerWidth / 2;
    const offsetY = event.pageY - window.innerHeight / 2;
    angle = Math.atan2(offsetY, offsetX);
  });

  function bubble(startX, startY, startSize, duration) {
    let animating = true;
    let finalSize = 10;

    const startTime = new Date();
    const bubble = document.createElement("div&.........完整代码请登录后点击上方下载按钮下载查看

网友评论0