Socket
Socket
Sign inDemoInstall

sprinkler

Package Overview
Dependencies
0
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sprinkler

Make awesome sprite rain effects on canvas. Give a canvas and a list of image paths and start() to make it rain!


Version published
Weekly downloads
35
decreased by-2.78%
Maintainers
1
Install size
119 kB
Created
Weekly downloads
 

Readme

Source

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

  • Snowfall
  • Money
  • Bananas

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

  • implementation.
  • tests

Versioning

Semantic Versioning 2.0.0

License

MIT License

Keywords

FAQs

Last updated on 03 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc