鱼游效果
代码语言:html
所属分类:粒子
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <style> body, canvas { margin: 0; overflow: hidden; background-color: black; } </style> </head> <body translate="no"> <canvas id=canvas></canvas> <script> let rnd = Math.random; let w = canvas.width = innerWidth; let h = canvas.height = innerHeight; let ctx = canvas.getContext("2d"); ctx.translate(w / 2, h / 2); ctx.textAlign = 'center'; ctx.textBaseline = "middle"; let pts = Array(99).fill(0).map(() => { let d = rnd() * Math.PI * 2; let size = rnd() * 22 + 11; return { size, dir: d, targetDir: d, speed: 1 + rnd() / size * 11, x: rnd() * w - w / 2, y: rnd() * h - h / 2 }; }); function draw(t) { requestAnimationFrame(draw); ctx.fillStyle = "#00000012"; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0