add opacity parameter

This commit is contained in:
Asif Bacchus 2020-04-10 05:04:02 -06:00
parent aec19308ab
commit 46770f4da3
1 changed files with 15 additions and 0 deletions

View File

@ -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;
}