canvas实现支持中文的自定义文字颗粒化粒子散落一地动画效果代码
代码语言:html
所属分类:粒子
代码描述:canvas实现支持中文的自定义文字颗粒化粒子散落一地动画效果代码
代码标签: canvas 支持 中文 自定义 文字 颗粒化 粒子 散落 一地 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Paytone+One&display=swap'> <style> :root { --foreground: #f5ff6e; --foreground-hover: #f8ff99; --background: #103b82; --background-lgt: #2561c4; } html * { box-sizing: border-box; } body { padding: 0; margin: 0; } body { background-color: var(--background); color: var(--foreground); position: relative; overflow: hidden; } button#restart { position: absolute; top: 1rem; right: 1rem; z-index: 3; padding: 0.75rem 1.5rem; border: none; background-color: var(--foreground); color: #000; border-radius: 0.25rem; cursor: pointer; } #input-container { position: absolute; left: 50%; top: 1rem; transform: translate3d(-50%, 0, 0); display: flex; align-items: center; gap: 0.5rem; } #input-container input { background-color: rgb(255 255 255 / 0.25); border: 3px solid var(--background-lgt); border-radius: 0.25rem; color: #fff; font-size: 1.25rem; } #select-word { /* font-size: 1.25rem; */ background-color: var(--foreground); border: none; border-radius: 0.25rem; padding: 0.5rem 1.5rem; } button#restart:hover, #select-word:hover { background-color: var(--foreground-hover); } canvas#oof-canvas { position: absolute; left: 0; right: 0; width: 100vw; height: 100vh; /* outline: 1px solid lime; */ z-index: 2; pointer-events: none; } </style> </head> <body translate="no"> <div id="input-container"> <input id="word" type="text" value="BFW" /> <button id="select-word">Clumsy me!</button> </div> <!-- <p>Oof</a> --> <!-- inspired by Edward Ruscha's OOF https://www.moma.org/collection/works/79298 --> <canvas id="oof-canvas"></canvas> <!-- <button id="restart">Restart</button> --> <script> console.clear(); const canvas = document.querySelector("#oof-canvas"); const ctx = canvas.getContext(".........完整代码请登录后点击上方下载按钮下载查看
网友评论0