From 46770f4da3fee52b6157586c18e8e933b5e58a5c Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 10 Apr 2020 05:04:02 -0600 Subject: [PATCH] add opacity parameter --- js/particles.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/particles.js b/js/particles.js index 806598c..8e68da0 100644 --- a/js/particles.js +++ b/js/particles.js @@ -21,6 +21,10 @@ function particles(){ let particlesArray; speed = (speed !== 0) ? (speed / 100) : 0; // index speed to base 100 = 1 + opacity = opacity / 100; + + // set overall canvas opacity + canvas.style.opacity = opacity; // get mouse position let mousePosition ={ @@ -179,6 +183,17 @@ function particles(){ animate(); function checkParams(){ + if (typeof opacity == 'undefined'){ + opacity = 100; + } + else if (Number.isFinite(opacity) && (0 <= opacity && opacity <= 100)){ + opacity; + } + else{ + opacity = 100; + console.log("'opacity' must be a finite number between 0 and 100. Using default of '100'."); + }; + if (typeof numParticles == 'undefined'){ numParticles = 1; }