erikwatson / snowfall.js

Stay cool ☃️
https://erikwatson.github.io/snowfall.js/
MIT License
4 stars 2 forks source link

Users should be able to have as many layers as they like. #40

Open erikwatson opened 1 month ago

erikwatson commented 1 month ago

This would make it possible for users to configure the snowfall simulation for different use-cases. For example, if instead of letting snowfall draw 2 layers we instead ran 2 single layer simulations we, the user are then able to construct a page with more depth. They could even respect their position in the layering when moving them on scroll (#15), creating a nice parallax effect.

Sounds good. Do it.

erikwatson commented 1 month ago

This has been kind of interesting. We want to have layers behave with some randomness, but they can't calculate their random values independently, so I had to lift the randomness up to the code above - passing the random values into the layers. This still doesn't quite do it, because the random values are created per layer based on the layer properties they would still come out with 2 unique random values despite having the same input. Added some seeded random number generator stuff in to solve this. Each layer uses the same seed, so then every value that goes in produces the same output, and we get consistent layer behaviour. Good.