canvas模拟可视化风粒子交互动画效果代码
代码语言:html
所属分类:粒子
代码描述:canvas模拟可视化风粒子交互动画效果代码
代码标签: canvas 模拟 可视化 风 粒子 交互 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { margin: 0; padding: 0; overflow: hidden; } </style> </head> <body translate="no"> <canvas id="c"> <script > const c = document.querySelector('#c'); const ctx = c.getContext('2d'); const dpr = Math.min(2, window.devicePixelRatio); c.width = window.innerWidth * dpr; c.height = window.innerHeight * dpr; c.style.imageRendering = 'pixelated'; c.style.width = '100vw'; c.style.height = '100vh'; const palette = [ '#f72585', '#b5179e', '#7209b7', '#560bad', '#480ca8', '#3a0ca3', '#3f37c9', '#4361ee', '#4895ef', '#4cc9f0']; const points = []; const createPoint = (x, y, color) => ({ x, y, color }); for (let i = 0; i < 500; i++) { points.push(createPoint( Math.random() * c.width, Math.random() * c.height, Math.floor(Math.ra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0