Catalog npm
Back to packageRELEASE DETAILS

1.4.2

npm

2d-canvas-image-particles

A simple lightweight 2D particle system using Canvas.

canvasparticles
Published12 Oct 2021
Direct dependencies4
Transitive dependenciesNot calculated

README

Current package documentation

2D Particle System using Canvas

A simple lightweight 2D particle system using Canvas.

  • Multiple particle systems can be bound to the same canvas
  • Particles speed remain the same regardless of the refreshing rate
  • Less than 10 KB
  • Refresh rate independant : particles have the same behaviour between 60hz / 144hz monitors

Check the demo page

Usage

  • Create a canvas
  • Import dist/2d-canvas-image-particles.min.js
  • Create a new ParticleSystem : new ParticleSystem(canvas_id, image_path, options);

Example

<canvas id="js-canvas"></canvas>

<script src="dist/2d-canvas-image-particles.min.js"></script>
<script>
    new ParticleSystem('js-canvas', 'images/default-particle.png', {
        cursorMode: CursorMode.Zoom
    });
</script>

You can check the demo page's sources for more examples. You can also use an HTMLCanvasElement instead of an id.

Usage with npm / Yarn

npm install 2d-canvas-image-particles or yarn add 2d-canvas-image-particles.

Then you can import it and use it

import '2d-canvas-image-particles';
// ...
new ParticleSystem('id', 'images/default-particle.png', {
    cursorMode: CursorMode.Zoom
});

You will need to specify your own images.

Options

{
    maxParticles: number,
    velocityAngle: [min, max],
    speed: [min, max],
    rotationStartAngle: [min, max],
    cursorMode: CursorMode,     // (CursorMode.Bounce, CursorMode.Zoom, CursorMode.Light, CursorMode.Follow),
    rotationMode: RotationMode, // (RotationMode.None, RotationMode.Random, RotationMode.FollowVelocity)
    rotationSpeed: [min, max],
    rotationSpeedSizeScale: number
    minimumRotationSpeed: number // if min is negative and max is positive
    tints: [new Tint('#hexColor', opacity)],
    width: [min, max],
    height: [min, max],
    addOnClickNb: number,
    density: number,
    cursorRadius: number
}

Cursor Modes

  • CursorMode.Bounce: particles will bounce off the cursor.
  • CursorMode.Zoom: the closer the cursor is, the bigger the particles are.
  • CursorMode.Light: works with Tint. Particles will enlight when cursor is close.
  • CursorMode.Follow: generates particles that are following the cursor.

Rotation Modes

  • RotationMode.None
  • RotationMode.Random
  • RotationMode.FollowVelocity: Will follow the specified velocity (use it with CursorMode.Bounce so the particles go back to their base velocity, this is used for the rain example)

Build from sources

  • npm install
  • npm run build

IE Support

  • IE9+

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 4

Native requirements
4 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ts-loader
Environment
{
  "local_name": "ts-loader",
  "alias": false,
  "peer_metadata": null
}
^0.9.4development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^2.0.3development
typings
Environment
{
  "local_name": "typings",
  "alias": false,
  "peer_metadata": null
}
^1.4.0development
webpack
Environment
{
  "local_name": "webpack",
  "alias": false,
  "peer_metadata": null
}
^1.13.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-UWwNYlu32jFz6Ra5AIB4lc6zRwW9ugpTozX5PH3HMaTjNOc5r9T0WKdPWFPWu6/zASm+pMsQiYoF9aMj1FoKGw==",
  "shasum": "ecf06b01bdfd87c68b757bed54ef7b95c04ea0da",
  "tarball": "https://registry.npmjs.org/2d-canvas-image-particles/-/2d-canvas-image-particles-1.4.2.tgz",
  "fileCount": 24,
  "unpackedSize": 57554,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhuebECRA9TVsSAnZWagAAT00P/13XMCRdduHCF3T699nM\nB67uAJcZFRJPnciMUf/H7QrnvR2P9knt9KXulkXQVwJaJ+54Q9xq1+hWy6P4\nuLjgfKsAKBbyt5hBy/urU0KlFYLTXUmigTxDKrZkUmBRVitqbT0F0K/Lq03D\nX4Xr5FFEinCY2bjLelg6qLT312bX3Nqs+0ArRzCdOdNplgpa9jEFw2X3jVjS\ncn7NSFYFFlXo4niqmV6xLJ0eg0+P+HVC25l9dx6LNjO/IYE25dbLgS52NsSf\n6SS/ZqPHq8G9Os36pyKaTYVwBMYVtFCu2o6/RkjwRrwwDoUjdV7zlSiloDme\nyb9CaK3tPgG2b6ATWN5bLRm4nRn5UhLkevorvltY9MIGOBu4f5aKsESlo5xX\n/BeN8xYHCNyb2rQNKbFhBdXZRWjMTsbDgEFj7o1uO+1GalIF/ziHmvoKQM6a\niYvU4pDY1uUcpkO+vtT9AllKIyqnLP09VsnyYoIOm6xFucvdSRsX5IkfqCwq\nKYdY8uB2M8pKqgpbjUrFTcRNJ/MjDUD0oOiZoeHER93W56fw6opb0I97I0dT\nSFo5xPbI19vnDjJutIGPL+6JV/6Sy11DFj5/YG29VtZiBrDdECesAMmmMKtC\nVLVW8hC4elxvG13zYtX5KPgbT7RUDxWBqO43tgSjHZeI8VGNtKIZGT2VU3df\nxONi\r\n=u+Un\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQCtBWMYS8D2eiIzdr+Ol3LdM2cJNHu0xnTQWRGHx0Kx0gIgcvP1KK4nV+TS96MOUwmRL8T7cwKnc+esBmFZpmi1JOU="
    }
  ]
}

Repository

PENDING
arkounay/2d-canvas-image-particles

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:10 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:a007eaa4cb11882a0f817c89934224eb7bd8c4c04e180ecc1db9246dfd3f7336

Other collected versions

1.0.612 Oct1.0.412 OctView all collected versions →