change particle number calculation
Based on 1% of window width. numParticles is a straight multiplier, so increment percentage. Simple.
This commit is contained in:
parent
d22516867b
commit
bbf7e3d2f2
@ -101,7 +101,8 @@ function particles(){
|
|||||||
// create particle array
|
// create particle array
|
||||||
function init(){
|
function init(){
|
||||||
particlesArray = [];
|
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++){
|
for (let i = 0; i < numberOfParticles * numParticles; i++){
|
||||||
let size = (Math.random() * sizeMultiplier) + 1;
|
let size = (Math.random() * sizeMultiplier) + 1;
|
||||||
let x = (Math.random() * ((innerWidth - size * 2) - (size * 2)) + size * 2);
|
let x = (Math.random() * ((innerWidth - size * 2) - (size * 2)) + size * 2);
|
||||||
@ -195,14 +196,14 @@ function particles(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof numParticles == 'undefined'){
|
if (typeof numParticles == 'undefined'){
|
||||||
numParticles = 1;
|
numParticles = 10;
|
||||||
}
|
}
|
||||||
else if (Number.isFinite(numParticles)){
|
else if (Number.isFinite(numParticles)){
|
||||||
numParticles;
|
numParticles;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
numParticles = 1;
|
numParticles = 10;
|
||||||
console.log("'numParticles' must be a finite number. Using default of '1'.");
|
console.log("'numParticles' must be a finite number. Using default of '5'.");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof sizeMultiplier == 'undefined'){
|
if (typeof sizeMultiplier == 'undefined'){
|
||||||
|
Loading…
Reference in New Issue
Block a user