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-..........完整代码请登录后点击上方下载按钮下载查看
网友评论0