p5实现canvas爆炸粒子旋转效果代码
代码语言:html
所属分类:粒子
代码描述:p5实现canvas爆炸粒子旋转效果代码,点击任意地方就能形成一个粒子爆炸碎片。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; padding: 0; height: 100vh; overflow: hidden; display: flex; align-items: center; justify-content: center; background: black; } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.4.0.js"></script> <script > //click to add //press key to reset let sArray = []; let cArray = []; let t; let n = 500; //change for fun, but too many will be too much function setup() { c = min(windowWidth, windowHeight); cnv = createCanvas(windowWidth, windowHeight); microR = c / 5; fill(255); for (let i = 0; i < n; i++) { sArray.push(new star()); } noStroke(); tmp = random(0, c / 3); cArray[0] = createVector(tmp, 0, c / 2 - tmp); } function draw() { t = .........完整代码请登录后点击上方下载按钮下载查看
网友评论0