diff --git a/src/parallax-css-testpage/particles.js b/src/parallax-css-testpage/particles.js index 1df4b28ec724f16ef5ad8dce74d984325e1d12be..b49af6abca7115a9171be3f4bf2d513efd944217 100644 --- a/src/parallax-css-testpage/particles.js +++ b/src/parallax-css-testpage/particles.js @@ -66,9 +66,6 @@ function RandomPoint2D(minMaxX, minMaxY) { return Point2D( x, y ) } -function Particle({ position, direction, size, color }) { - return { position, direction, size, color } -} // @@ -216,7 +213,12 @@ function Animate(scene, particles) { } } -function CreateScene({ canvasId, contentId, depth, fps }) { +function CreateScene(cfg) { + var canvasId = cfg.canvasId, + contentId = cfg.contentId, + depth = cfg.depth, + fps = cfg.fps + var contentNode = document.getElementById(contentId), height = getNodeHeight(contentNode), width = window.innerWidth, @@ -243,19 +245,19 @@ function CreateScene({ canvasId, contentId, depth, fps }) { } -function CreateParticles(scene, { - density, - color, - size, - speed, - lifespan, -}) { +function CreateParticles(scene, cfg) { + var density = cfg.density, + color = cfg.color, + size = cfg.size, + speed = cfg.speed, + lifespan = cfg.lifespan + return Array.from( { length: calcParticleCount(scene, density) }, - function createParticle() { - return Particle({ + function Particle() { + return { position: RandomPoint2D( MinMax(0, (scene.width - (size * 2))), @@ -278,7 +280,7 @@ function CreateParticles(scene, { : +1, }, color - }) + } } ) }