js+svg实现跟随鼠标的头像聚合动画效果代码
代码语言:html
所属分类:动画
代码描述: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.15c.05 0 .06 0 0 0 .53-.1.63-.16 1.14-.22a15.51 15.51 0 0 0 1.89-.32v.43c4.73.72 8.24-1.63 8.86-6a215.51 215.51 0 0 1 5.68-29.12 12.47 12.47 0 0 0 .14-5.62z" fill="#efb28e"/></svg> <svg id="hair" class="blobby-bit" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 231.19 292.49"><title>blobby</title><path d="M195.5 65.78c2 12-1 79 13 80h.05l.27-.37c1.67-2.07 3.5-4 5.1-6.14a5.51 5.51 0 0 0 1.29-3.14c-.46-10.43-.44-20.93-1.79-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.23a4 4 0 0 0 .67 2.45c1.74 2.59 3.6 5.09 5.42 7.63a.14.14 0 0 1 0 .06l-.08-.09c.12.71.32 1.43.42 2.13a23.51 23.51 0 0 0 3.87-10.58c1-8-1-17 1-29s6-41 11-47 16-19 15-19 14-9 23-6 26 5 26 5 10 6 16 5 16.88-5.05 22.94-5 22.06 2 26.06 2 27.05 10.95 29.05 22.95z" fill="#cd8f3b"/> </svg> <svg id="outline" class="blobby-bit" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 231.19 292.49"><path d="M228.43 140.49a6.93 6.93 0 0 0-6.87-3.75H218c0-.15-.05-.29-.07-.43v-2.48c-.39-7.47-.28-15-1.3-22.4-2.18-15.81-4.57-31.61-7.64-47.26a115.77 115.77 0 0 0-3.09-12.4A62.44 62.44 0 0 0 200.51 39a56.27 56.27 0 0 0-18.78-20.77 74.3 74.3 0 0 0-11.54-6.59c-7.44-3.08-14.94-6.4-22.75-8.1-9.1-2-18.53-2.5-27.85-3.31a49.77 49.77 0 0 0-12.38.36c-16.85 2.82-33.45 6.73-48.8 14.56a55.5 55.5 0 0 0-10.47 7.5c-2.6 2.23-4.7 5-7 7.62A66.67 66.67 0 0 0 27 55.41c-3.14 10.35-5.55 20.94-7.86 31.52-3.39 15.5-6.52 31.07-6.61 47a19.21 19.21 0 0 1-.35 2.6 15.18 15.18 0 0 1-2.26.16c-3.47-.32-5.84 1.31-7.57 4.13A15.86 15.86 0 0 0 .89 154.5a64.59 64.59 0 0 1 3.47 17.6 37.46 37.46 0 0 0 2.11 11.25c1.65 4.59 4.81 7.41 9.64 5.92a3.64 3.64 0 0 1 1.43 0c.86 8.49 1.86 16.59 2.46 24.73.88 11.94 5.17 22.52 11.86 32.3a10.11 10.11 0 0 1 1.44 4.33c1.46 11.65 3.3 23.2 8.11 34.07a3.49 3.49 0 0 1 .15 2.08c.39.07.78.14 1.17.23a10.7 10.7 0 0 1 1.72-1.77 3.13 3.13 0 0 1-.77-1.43c-1.91-8.95-3.84-17.89-5.68-26.81-.65-3.18-1-6.42-1.62-9.61a6.51 6.51 0 0 0-1.21-3c-7.27-8.21-9.76-18.38-11.42-28.71-1.3-8.06-1.65-16.26-2.43-24.39-.07-.69-.14-1.38-.24-2.06-.69-4.62-.79-4.7-5.25-3.24-1.8.59-3.5.41-4.45-1.23-1.31-2.25-3.08-4.66-3.21-7.08a134.61 134.61 0 0 0-4.49-26.39c-1.45-5.56-.19-8.3 3.77-10.7 3.18-1.93 6.21-1.27 8 2 1.13 2.06 1.76 4.39 2.86 6.48.41.78 1.48 1.22 2.26 1.81a8.23 8.23 0 0 0 1.08-2.47 13.09 13.09 0 0 0-.47-3.18l.08.09a.14.14 0 0 0 0-.06c-1.82-2.54-3.68-5-5.42-7.63a4 4 0 0 1-.67-2.45c.79-8.42 1.28-16.9 2.63-25.23A468.62 468.62 0 0 1 28.45 60C32 47.12 38.74 36.24 47.9 26.66a50.7 50.7 0 0 1 20.52-12.88 221.81 221.81 0 0 1 34.13-9.44C111.27 2.78 120 3 128.74 3.83c10 1 20 2.33 29.53 5.66 17 5.94 31.57 15.43 40.82 31.35 3.8 6.53 5.75 14 7.06 21.51 1.34 7.8 2.84 15.58 4.23 23.37.67 4.41 1.38 8.9 2.18 13.32.07.38.14.79.21 1.18.22 1.55.44 3.1.65 4.66 1.35 10.32 1.33 20.82 1.79 31.25a5.51 5.51 0 0 1-1.29 3.14c-1.6 2.12-3.43 4.07-5.1 6.14-1 1.22-1.69 2.76-.1 3.86s2.5-.29 3.26-1.51a16.66 16.66 0 0 1 2-3.25c1.43-1.41 3-3 4.76-3.72 4.41-1.74 8.18.42 9 5a12.47 12.47 0 0 1-.12 5.54 215.51 215.51 0 0 0-5.62 29.16c-.62 4.34-4.13 6.69-8.86 6a9.64 9.64 0 0 0 0-2.46c-.2-.75-.94-2-1.17-2-.93.23-2.17.69-2.52 1.43a11.22 11.22 0 0 0-.48 3.76c-.68 8.54-.61 17.21-2.22 25.57a83.54 83.54 0 0 1-7.75 23.42c-2.61 5-5.14 10-7.91 14.84-1.71 3-3.09 5.83-3.32 9.52a61.44 61.44 0 0 1-4.89 20.32c-1.07 2.54-1.81 5.24-3.09 7.66a26.83 26.83 0 0 1-1.77 3 6.68 6.68 0 0 1 1.68.42c.49.19 1 .37 1.48.54a9.5 9.5 0 0 1 .82-1.28l-.28-.11c1.77-4.4 3.2-8.72 5.2-12.75 2.84-5.74 2.84-12 3.77-18.06a14 14 0 0 1 1.92-6c7-10.61 11.59-22.37 15.52-34.38 2.84-8.68 3.58-17.75 4.21-26.81.1-1.37 0-2.89 2.11-2.79 5.22.24 10.6-5 11.43-10.58.65-4.38.91-8.82 1.52-13.21a18.38 18.38 0 0 1 1.48-4.67c3.05-7.24 3.28-14.36-.45-21.38z"/><path d="M217 166.9c-.15 1.14-1 2.18-1.14 3.32-.12.73.41 1.56.77 2.77a22.38 22.38 0 0 0 2-1.62 8.31 8.31 0 0 0 1.29-10 7.73 7.73 0 0 1 .7-9.28c1-1.31 2.27-2.44 3.25-3.78a9.18 9.18 0 0 0 .91-2.4 8.45 8.45 0 0 0-2.61.45 14.41 14.41 0 0 0-3.05 2.29c-4.37 4.13-5 8.92-2.35 14.36a7.21 7.21 0 0 1 .23 3.89zM15.83 160c2.22-5-.71-8.11-3.32-11.33-1.35-1.67-3.43-2.07-5.81-.3a9.35 9.35 0 0 0 1.37 1.2c4 2.12 5.43 5.82 4.06 10a15.45 15.45 0 0 0-.82 4.9A4.56 4.56 0 0 0 14.4 169a2.41 2.41 0 0 0 2.1-.18c.35-.39.05-1.39 0-2.12-.28-2.26-1.5-4.93-.67-6.7zM117.71 43.24c.91-.11 1.55-2.35 2.32-3.62l-.5-.38a21.15 21.15 0 0 0-.5-3.48 2.22 2.22 0 0 0-3.24-1.55c-.65.35-.86 1.87-.9 2.88a9.47 9.47 0 0 0 .74 2.52c.37 1.46-.51 3.96 2.08 3.63zM156.72 42.86c1.45.37 2.41-.39 2.4-2.11 0-1 .5-2 .34-2.9s-.89-2.15-1.38-2.16a3.31 3.31 0 0 0-2.45 1.38c-.58 1-.6 2.25-1 4.08.53.47 1.21 1.49 2.09 1.71zM140.41 43a20.17 20.17 0 0 0 2.06-3.41c.42-1.07.78-2.63.31-3.5-.72-1.31-2-.84-2.75.4a32.72 32.72 0 0 0-1.95 3.88c-.61 1.47.22 2.73 2.33 2.63zM104.36 42c.31.09 1.17-.69 1.3-1.19.36-1.5-2.87-5.95-4.34-5.88-.16.1-.77.36-.75.5a25.22 25.22 0 0 0 1.29 5.15c.32.75 1.58 1.18 2.5 1.42zM129.4 42.57c1.24-.32 2-2.56 3.19-4.24-1-1.19-1.71-2.63-2.39-2.63-2.34 0-2.63 1.92-2.59 3.75.03 1.37-.28 3.64 1.79 3.12zM172.35 37.38c-1.46-.42-3.14 1.47-3.39 4.13a7.13 7.13 0 0 0 1.85 1.73c.9.44 3.46-2.32 3.28-3.74a3.07 3.07 0 0 0-1.74-2.12zM94 39.83c.06 0 .06-.19.08-.28.........完整代码请登录后点击上方下载按钮下载查看
网友评论0