p5实现彩色圆点喷射粒子动画效果代码
代码语言:html
所属分类:粒子
代码描述:p5实现彩色圆点喷射粒子动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { box-sizing: border-box; } html, body { margin: 0; padding: 0; } canvas { width: 500px; height: 500px; max-width: 100vw; max-height: 100vh; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } </style> </head> <body translate="no"> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.7.0.js"></script> <script > console.clear(); const count = 2000; const dots = []; const maxRad = Math.min(window.innerWidth, window.innerHeight) * .5; const startRad = maxRad * .025; const endRad = maxRad * .9; const playRad = endRad - startRad; const bgHue = Math.floor(Math.random() * (360)); const fgHue = (bgHue + 180) % 360; class Dot { constructor(){ this.reset(); this.life = Math.random(); } reset(){ this.angle = random(TAU); this.life = 0; this.rand = Math.random() * 1000; this.speed = Math.random() * .01; this.angleSpeed = Math.random() * .001 * (Math.random() > .5 ? 1 : -1); this.saturation =.........完整代码请登录后点击上方下载按钮下载查看
网友评论0