pour is lightweight particle system.


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.

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.

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 Particles, Emitters and Fields together.

var system = pour.s();    // shorthand for `new pour.System()` 

We also set up an Emitter that emits Particles and add it to our System.

var emitter = pour.e({    // shorthand for `new pour.Emitter(…)` 
    position: new pour.Vector(250, 250),    // the position of the emitter 
    velocity: new pour.Vector(1, 0),        // the direction & velocity of the particles 
    spread: Math.PI / 4                     // 45 degrees spread (in radians) 

Everytime we call emit, the Emitter emits a new Particle.

var particle = emitter.emit();

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 Particles will then move according to their current velocity.

system.tick();    // one step further… 

By adding a Field, we can influence all Particles in our System. A positive mass of a Field will attract them, a negative will repulse them.

field = pour.f({    // shorthand for `new pour.Field(…)` 
    position: pour.v(100, 50)    // shorthand for `new pour.Vector(…)` 

coming soon!

If you have a question, found a bug or want to propose a feature, have a look at the issues page.