pour
pour is a lightweight JavaScript particle system able to simulate particles, emitters and fields. It is flexible because it has no rendering code and works step-based instead of time-based.
pour has a simple and straightforward API and embraces prototypal programming, keeping it below 4kb (minified). In addition, it supports both browser- and node-based environments. pour is licensed under the MIT license.
Install
If you want to go with the default build, download the latest release from the releases page. The JavaScript files will be in the dist
folder.
Getting Started
Let's simulate the path of a particle being attracted by a field.
To begin, we set up an empty particle system. A System
holds all Particle
s, Emitter
s and Field
s together.
var system = pour; // shorthand for `new pour.System()`
We also set up an Emitter
that emits Particle
s and add it to our System
.
var emitter = pour;system;
Everytime we call emit
, the Emitter
emits a new Particle
.
var particle = emitter;
If we add the Particle
to the System
, we can compute its path by calling system.tick()
. Each call to tick
simulates one atomic step. All Particle
s will then move according to their current velocity
.
system;system; // one step further…
By adding a Field
, we can influence all Particle
s in our System
. A positive mass
of a Field
will attract them, a negative will repulse them.
field = pour;system;system;
Documentation
coming soon!
Contributing
If you have a question, found a bug or want to propose a feature, have a look at the issues page.