canvas实现波动的曲线艺术美动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现波动的曲线艺术美动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@100&display=swap'> <style> body { margin: 0; overflow: hidden; display: flex; justify-content: center; align-items: center; height: 100vh; background: #000; } canvas { display: block; } </style> </head> <body translate="no"> <canvas id="waterCanvas"></canvas> <script > const canvas = document.getElementById('waterCanvas'); const ctx = canvas.getContext('2d'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; const waves = []; const waveCount = 25; for (let i = 0; i < waveCount; i++) { waves.push({ y: canvas.height / 2 - 100 + Math.random() * 200, // 中央付近に分布 length: 0.01 + Math.random() * 0.001, amplitude: 50 .........完整代码请登录后点击上方下载按钮下载查看
网友评论0