This package has been deprecated

Author message:

This package is outdated and unmaintained.

pour

0.3.0 • Public • Published

pour

npm version bower version build status dev dependency status

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 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)
});
system.add(emitter);

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.add(particle);
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(…)`
});
system.add(field);
system.tick();

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.

Package Sidebar

Install

npm i pour

Weekly Downloads

9

Version

0.3.0

License

ISC

Last publish

Collaborators

  • derhuerst