sprinkler.jsv0.3.0
With Sprinkler you can make awesome sprite rain effects on canvas. Give it a canvas element and a list of image paths and call start() to make it rain bananas or frogs or anything you can imagine!
Examples
Usage
The following will make the canvas rain snowflakes.
var c = document.getElementById('canvas');
var s = Sprinkler.create(c);
var images = [
'img/snowflake.png',
'img/snowflakeb.png',
'img/snowflakec.png'
];
s.load(images, function (start) {
start();
});
Installation
Browsers
<script src="scripts/sprinkler.js"></script>
CommonJS & Node.js
$ npm install sprinkler
---
> var Sprinkler = require('sprinkler');
AMD & Require.js
define(['scripts/sprinkler'], function (Sprinkler) { ... });
API
Sprinkler.create(canvasElement)
Create a sprinkler animation on the given canvas.
#load(imagePaths, callback(start))
imagePaths
, an array of image source paths.
start(options)
Start animation. start
is given via load
callback.
Returns a stop
function that stops the animation.
Optional options
object can take following properties:
- selectImages, an array of indices of the images to be used
- imagesInSecond, an average number of dropped images in a second
stop()
Stops the animation. stop
is returned by start
.
Notes for developers
Run tests with $ npm test
.
Build with $ npm run build
.
Serve with $ npm start
.
Todo
Versioning
Semantic Versioning 2.0.0
License
MIT License