From bbf7e3d2f296bf4075399e164aebd048112cc0f4 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 10 Apr 2020 08:51:16 -0600 Subject: [PATCH] change particle number calculation Based on 1% of window width. numParticles is a straight multiplier, so increment percentage. Simple. --- js/ab-particles.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/ab-particles.js b/js/ab-particles.js index e65c509..d4444c5 100644 --- a/js/ab-particles.js +++ b/js/ab-particles.js @@ -101,7 +101,8 @@ function particles(){ // create particle array function init(){ particlesArray = []; - let numberOfParticles = (canvas.height * canvas.width) / 9000; + //let numberOfParticles = (canvas.height * canvas.width) / 9000; + let numberOfParticles = canvas.width * 0.01; for (let i = 0; i < numberOfParticles * numParticles; i++){ let size = (Math.random() * sizeMultiplier) + 1; let x = (Math.random() * ((innerWidth - size * 2) - (size * 2)) + size * 2); @@ -195,14 +196,14 @@ function particles(){ }; if (typeof numParticles == 'undefined'){ - numParticles = 1; + numParticles = 10; } else if (Number.isFinite(numParticles)){ numParticles; } else{ - numParticles = 1; - console.log("'numParticles' must be a finite number. Using default of '1'."); + numParticles = 10; + console.log("'numParticles' must be a finite number. Using default of '5'."); }; if (typeof sizeMultiplier == 'undefined'){