1.2.6 • Published 5 years ago

carbonator v1.2.6

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Carbonator

Carbonate the web.

JQuery plugin based on bubblr by Mikey Hogarth.

Usage

Install the library:

npm install --save carbonator

Require the module:

require('carbonator');

JQuery should now be able to initialize carbonation on an HTML div via the carbonate function:

$('div.flat').carbonate();

A canvas element will be created and appended to the div, and will resize automatically to match its parent.

Options

The following options may be passed to the carbonate function:

optiondescriptiondefault
animationIntervalinverval between animation frame requests (ms)1000 / 24 (24 FPS)
backgroundColorbackground color of the container element'transparent'
bubbleColorcolor of the bubbles'white'
bubbleDensitynumber of bubbles to draw per pixel of canvas area0.0005
bubbleFluttermaximum range bubble may move in either direction (px/frame)0.1
bubbleGrowthFactorMinminimum bubble growth rate1 (no growth)
bubbleGrowthFactorMinpossible bubble growth rate in excess of minimum0.002
bubbleOpacityopacity of the bubbles0.7
bubbleRadiusMinminimum range of each bubble (px)1
bubbleRadiusRangepossible bubble radius in excess of minimum2
bubbleSpeedMinminimum movement speed of each bubble (px/frame)3
bubbleSpeedRangepossible bubble movement speed in excess of minimum2
hotspotDensitynumber of hotspots to generate per pixel of width0.0025
hotspotProbabilityMinminimum chance per frame for hotspot to generate bubble0.25
hotspotProbabilityMaxmaximum chance per frame for hotspot to generate bubble0.75
hotspotRespawnRatechance per frame that hotspot will be deleted and regenerated at a different location1 / (24 * 10) (about every 10 seconds)
beforeDrawfunction to call before drawing each frame (passed Canvas​Rendering​Context2D) †undefined
afterDrawfunction to call after drawing each frame (passed Canvas​Rendering​Context2D) †undefined

† callbacks are bound to the Carbonator instance; internal properties may therefore be accessed through this, but such behavior may be subject to breaking changes

You Might Not Need JQuery

While this library is designed to be used as a JQuery plugin, JQuery is not required and is not included as a dependency. Alternatively, the constructor may be accessed directly from the imported module, or through a function attached to itself:

const Carbonator = require('carbonator');

// call via constructor
new Carbonator(document.querySelector('div.flat'), options);

// call via factory method
Carbonator.carbonate(document.querySelector('div.flat'), options);
1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago