canvas实现闪电电流波纹动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现闪电电流波纹动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { margin: 0; padding: 0; height: 100dvh; width: 100dvw; overflow: hidden; background: black; display: grid; place-items: center; position: relative; } </style> </head> <body translate="no"> <canvas id="canvas"></canvas> <script > const ctx = canvas.getContext("2d"); const pointsCount = 5000; let centerX; let centerY; let points = []; let pos; const updateSize = () => { canvas.width = window.innerWidth; canvas.height = window.innerHeight; centerX = canvas.width / 2; centerY = canvas.height / 2; ctx.fillStyle = "black"; ctx.fillRect(0, 0, canvas.width, canvas.height); pos = { x: 0, y: centerY }; points = new Array(pointsCount).fill(0).map(() => ({ x: 0, y: centerY })); .........完整代码请登录后点击上方下载按钮下载查看
网友评论0