Blizzard v0.1

An instant snowstorm on your website


Installation

To use Blizzard, you'll need to download/copy the built JavaScript (here, 1.6KB) into a file that you can import via <script src>.

Usage

Blizzard adds a class to the window object. It's at window.Blizzard.

Instantiate the class with 2 arguments: an HTMLCanvasElement and an object (options).

Then, you can use the .play() and .pause() methods on the instantiated class.

Options

Option Type Description Default value
amount Number Amount of snowflakes 200
size Number Size multiplier...basically size 1
movement Number Oscillation intensity, how much they move from side to side 20
fallSpeed Number How fast they fall 0.5
respawn Number After (respawn * windowHeight) pixels, you see the same snowflake again — in other words, lower = more repetitive patterns 2
focus Number, 0-9 The z position the "camera" is "focused" on. 9 means it's focused on the closest snowflakes, blurring the farthest snowflfakes. 0 is the opposite. 9
fStop Number, 0-1 Blur intensity; how much the focused z position is focused, kind of. 1 will disable focusing completely. 1
Note! Performance is affected when using depth of field (focus/fStop), due to canvas filters. There is a better way to blur snowflakes (gradients). That will come in a later version if it's better on performance.

Example

let blizzard = new window.Blizzard(c, {
    amount: 350,
    size: 0.2
}).play();