npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

canvas-particle-network

v1.5.0

Published

Simple animated particle network using Canvas and JavaScript

Downloads

220

Readme

Canvas Particle Network

NPM version Bower version NPM dependencies NPM devDependencies NPM total downloads

Overview

In this experiment, I set out to build a simple, sexy, interactive, and animated particle network using Canvas and JavaScript. Fully plug n' play, modular (via Browserify and WebPack), and customisable, just drop it in any webpage.

See it live on CodePen

Alternatively, fork the repo and open demo.html to give it a whirl; the minified version comes in at just under a cheeky 4KB uncompressed, and 1.3KB when gzipped!

Usage

The plugin is available as canvas-particle-network via Bower or NPM. Alternatively, you can simply clone this repository.

For a barebones implementation, simply add a HTML div to your body. You may specify its dimensions via CSS/JavaScript without any issues, as well as specify multiple instances. Then, simply add the JavaScript file to the end of your body and create a ParticleNetwork instance using your canvas ID.

<body>
	<div id="particle-canvas"></div>
	<script type="text/javascript" src="particle-network.min.js"></script>
	<script type="text/javascript">
		var particleCanvas = new ParticleNetwork(canvasDiv, options);
	</script>
</body>

Additionally, a number of options are supported (see below). Simply append any of these options to your arguments on creation.

var options = {
	particleColor: '#fff',
	background: '#1a252f',
	interactive: true,
	speed: 'fast',
	density: 'medium'
};
var particleCanvas = new ParticleNetwork(document.getElementById('particle-canvas'), options);

Options

options.particleColor

Type: String
Default: #ffffff

Color of the particles. Must be a valid hexadecimal code.

options.background

Type: String
Default: #1a252f

Specifies a background color or image to the canvas. Must be a valid image URL (e.g. img/demo-bg.jpg) or hexadecimal code.

options.interactive

Type: Boolean
Default: true

Allow users to click on the canvas to create a new particle. Its velocity will depend on the specified speed (see below).

options.speed

Type: String
Default: medium

Velocity of the particles. Must be one of the following:

  • none
  • slow
  • medium
  • fast

options.density

Type: String or Number
Default: medium (alias for 10000)

Density of the particles. Actual amount depends on the canvas size, and is calculate by dividing the total canvas size by the density. The following values are accepted:

  • low (or 20000)
  • medium (or 10000)
  • high (or 5000)
  • Any number

Please note that the higher the density, the more computationally intensive / slower each animation step becomes!

Roadmap

  • Have a suggestion? Let me know!

Contributors

A heartfelt thanks to the following people for making this project possible:

If you would like to contribute, please submit a pull request that passes the grunt eslint task.

Acknowledgements

This experiment was inspired by the following resources:

Release History

  • v1.5.0 | 2016-02-24 | Custom particle density support
  • v1.4.0 | 2016-01-14 | AMD & CommonJS module support
  • v1.3.3 | 2015-11-29 | Bug fix on window resizing
  • v1.3.2 | 2015-10-04 | Added files to bower.json ignore
  • v1.3.1 | 2015-10-04 | Bumped version due to NPM versioning conflict
  • v1.3.0 | 2015-10-04 | Added NPM and Bower releases
  • v1.2.1 | 2015-10-04 | Minor README fixes
  • v1.2.0 | 2015-10-04 | Replaced bgColor option with background, added speed option, and is now responsive
  • v1.1.0 | 2015-08-18 | Added minified release
  • v1.0.0 | 2015-08-17 | Initial release

License

The MIT License (MIT)

Copyright (c) 2015 Julian Laval

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.