1.0.1 • Published 6 years ago

squareparticles-js v1.0.1

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

squareParticles-js

A tiny Javascript library for creating square particles (it also supports collisions).

Usage

Using npm run:

$ npm install --save squareparticles-js

Using script, load using:

<script src="particles.min.js"></script>

Run using:

squareParticles({
    collision: true
});

Stop playing with:

var p = squareParticles();
p.stop()

Resume:

var p = squareParticles();
p.resume()

squareParticles Preview Image

Configuration

nametypedefaultdetail
countnumberwindow size dependantTotal number of particles
min_sizenumber2Minimum particle size
max_sizenumberwindow size dependantMaximum particle size
agingbooleantrueWhether or not particle color changes with time
colorfunction | array(3)-Function or array defining particle colors
canvasstring | DOMElementquerySelector('canvas')Canvas element where the rendering will happen
min_speednumber0.5Maximum particle speed
max_speednumber5Minimum particle speed
collisionbooleanfalseEnable or disable particle collisions

Example configuration object:

var config = {
    aging: false,
    color: [0, 255, 0],
    canvas: "#myCanvas",
    collision: true
}

License

MIT