@cycjimmy/canvas-snow

3.0.2 • Public • Published

Canvas Snow

libraries dependency status libraries sourcerank Coverage Status Release date rollup semantic-release jest npm license

  • Generates snow in canvas. (Demo)

Install

NPM version NPM bundle size npm download

# via npm
$ npm install @cycjimmy/canvas-snow --save

# or via yarn
$ yarn add @cycjimmy/canvas-snow

Usage

import CanvasSnow from '@cycjimmy/canvas-snow';

const canvasSnow = new CanvasSnow({
  ...options
}).init();
canvasSnow.start();
  • options

    • context: [Element|String] Context Wrapper Element.
    • cell: [Number] The maximum number of snow in the canvas.
    • width: [Number|String] Set canvas width with percentage and px units. Default '100%'.
    • height: [Number|String] Set canvas height with percentage and px units. Default '100%'.
  • Methods:

    • init(): Initialize to generate random snow.
    • start(): Start snow animation.
    • stop(): Stop snow animation.
    • clear(): Clear Generated random snow.

Use in browser

<div id="snowWrapper"></div>
<script src="canvas-snow.umd.min.js"></script>
<script>
  const canvasSnow = new CanvasSnow(source, {
    context: '#snowWrapper',
    [...options]
  }).init();

  canvasSnow.start();
</script>

CDN

jsdelivr

To use via a CDN include this in your HTML:

<script src="https://cdn.jsdelivr.net/npm/@cycjimmy/canvas-snow@3/dist/canvas-snow.umd.min.js"></script>

Readme

Keywords

Package Sidebar

Install

npm i @cycjimmy/canvas-snow

Weekly Downloads

19

Version

3.0.2

License

MIT

Unpacked Size

33.7 kB

Total Files

7

Last publish

Collaborators

  • cycdpo