js+svg实现跟随鼠标的头像聚合动画效果代码

代码语言:html

所属分类:动画

代码描述:js+svg实现跟随鼠标的头像聚合动画效果代码

代码标签: js svg 跟随 鼠标 头像 聚合 动画

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    body {
  overflow: hidden;
  min-height: 100vh;
  filter: url(#goo);
  cursor: none;
}

.blobby-bit {
  width: 160px;
  height: auto;
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

.blobby-bg {
  height: 240px;
  width: 240px;
  border-radius: 50%;
  background: #fbbb95;
}
</style>
  <script>
  setTimeout(() => {
    if (!location.pathname.match(/fullcpgrid/i)) return;
    globalState.mouseX = window.innerWidth / 2;
    globalState.mouseY = window.innerHeight / 2;
    let mult = 1;
    let useY = false;
    setInterval(() => {
      globalState[useY ? 'mouseY' : 'mouseX'] += 30 * mult;
      useY = !useY;
      if (useY) mult *= -1;
    }, 200);
  });
</script>

</head>
<body>
<!-- partial:index.partial.html -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <defs> 
    <filter id="goo">
      <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
      <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 200 -20" result="goo" />
      <feBlend in="SourceGraphic" in2="goo" />
    </filter>
  </defs>
</svg>

<svg id="base" class="blobby-bit" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 231.19 292.49"><path d="M227.82 145.83c-.67-3.55-3-5.64-6.11-5.63a2.6 2.6 0 0 0-1.58-.9c-1.7-.35-3.81-.38-5.61-.93a4.44 4.44 0 0 0 .7-2.24c-.47-10.43-.45-20.93-1.8-31.25-.21-1.56-.43-3.11-.65-4.66-.07-.39-.14-.8-.21-1.18-.8-4.42-1.51-8.91-2.18-13.32-1.39-7.79-2.89-15.57-4.23-23.37-1.31-7.52-3.26-15-7.06-21.51-9.25-15.92-23.77-25.41-40.82-31.35-9.56-3.33-19.49-4.69-29.53-5.66-8.74-.83-17.47-1.05-26.19.51a221.81 221.81 0 0 0-34.13 9.44A50.7 50.7 0 0 0 47.9 26.66C38.74 36.24 32 47.12 28.45 60a468.62 468.62 0 0 0-10.67 50c-1.35 8.33-1.84 16.81-2.63 25.23v.07a24.21 24.21 0 0 1-2.15 3.15c-.51.62-1.13.67-1.95 1l-.13.06a6.64 6.64 0 0 0-3.48 1.08c-4 2.4-5.22 5.14-3.77 10.7a134.61 134.61 0 0 1 4.49 26.39c.13 2.42 1.9 4.83 3.21 7.08.95 1.64 2.65 1.82 4.45 1.23 4.46-1.46 4.56-1.38 5.25 3.24.1.68.17 1.37.24 2.06.78 8.13 1.13 16.33 2.43 24.39 1.66 10.33 4.15 20.5 11.42 28.71a6.51 6.51 0 0 1 1.21 3c.61 3.19 1 6.43 1.62 9.61 1.66 8.08-.69 23.13 5.69 26.86s41.62 7.07 69.28 5.95 62.09 1.42 69.33-2.29c1.89-1.17.5-6.5.53-6.58a61.44 61.44 0 0 0 4.89-20.32c.23-3.69 1.61-6.52 3.32-9.52 2.77-4.87 5.3-9.88 7.91-14.84a83.54 83.54 0 0 0 7.77-23.43c1.57-8.18 1.55-16.66 2.18-25a2.66 2.66 0 0 0 1.22-1.1.........完整代码请登录后点击上方下载按钮下载查看

网友评论0