canvas实现数字粒子汇聚交互动画效果代码
代码语言:html
所属分类:粒子
代码描述:canvas实现数字粒子汇聚交互动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> #count { display: none; } canvas { display: none; } :root { --tile-size: 0.7vmin; --distance: 1vmin; } @property --x { syntax: "<length>"; initial-value: 0; inherits: true; } @property --y { syntax: "<length>"; initial-value: 0; inherits: true; } @property --scale { syntax: "<number>"; initial-value: 1; inherits: true; } #tiles { filter: drop-shadow(0 0 1rem #b818da); width: 0dvw; height: 0dvh; display: grid; place-items: center; cursor: pointer; } #tiles > div { border-radius: 50%; width: var(--tile-size); aspect-ratio: 1; background: hsla(var(--color), 110%, 60%, 1); position: absolute; transform: translate3d(var(--x), var(--y), 0) scale(var(--scale)); --delay: calc(var(--p-r) * 1s); --color: calc(var(--p-r) * (360 - 100) + 100); --duration: calc(var(--p-r2) * 10s); } #tiles.show > div { -webkit-animation: fade-in 0.3s linear forwards, show var(--duration) var(--delay) cubic-bezier(0.86, 0.86, 0.41, 1.16) infinite, blink 1s var(--delay) ease-in-out infinite; animation: fade-in 0.3s linear forwards, show var(--duration) var(--delay) cubic-bezier(0.86, 0.86, 0.41, 1.16) infinite, blink 1s var(--delay) ease-in-out infinite; } @-webkit-keyframes blink { from, 50%, to { opacity: 1; } 30%, 70% { opacity: 0.3; } } @keyframes blink { from, 50%, to { opacity: 1; } 30%, 70% { opacity: 0.3; } } @-webkit-keyframes fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } } @-webkit-keyframes show { from { --x: calc(1dvw * var(--p-r)); --y: calc(-100dvh * var(--p-r)); filter: blur(0.5rem); --scale: calc(clamp(1.5, 10 * var(--p-r2), 5)); } 5% { filter: blur(0rem); } 10% { --x: calc(var(--p-x) * var(--distance)); --y: calc(var(--p-y) * var(--distance)); --scale: calc(1); } to { --x: calc(var(--p-x) * var(--distance)); --y: calc(var(--p-y) * var(--distance)); } } @keyframes show { from { --x: calc(1dvw * var(--p-r)); --y: calc(-100dvh * var(--p-r)); filter: blur(0.5rem); --scale: calc(clamp(1.5, 10 * var(--p-r2), 5)); } .........完整代码请登录后点击上方下载按钮下载查看
网友评论0