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

plasma-demo

v1.0.0

Published

Plasma animation in a canvas.

Downloads

3

Readme

PlasmaJS

By Carl Gorringe

A colorful Plasma demo, written in Javascript, which renders inside an HTML canvas tag.

Visit my demo page to see it run!

How To Use

Simply insert a canvas tag and the plasma.js file somewhere into your HTML's body like so:

<canvas id="plasma-canvas" width="400" height="400"></canvas>

<script src="plasma.js"></script>
<script>
	var plasma = new PlasmaJS({
		canvasId: 'plasma-canvas',
		palette: 'rainbow'
	});
</script>

Constructor Parameters

  • canvasId : Required.
  • palette : Optional. Choose from rainbow, nebula, fire, bluegreen, or rgb. The default is rainbow.
  • timeInterval : Optional. Default is 50 milliseconds delay between frames. Specify a larger number to slow down the animation, or smaller number to speed it up.

Methods

For the example above, call plasma.start() to begin the animation.

  • .start() : Start or resume the animation.
  • .stop() : Stop or pause the animation.
  • .reset() : Reset to the first frame.
  • .clear() : Clears the canvas. Only stays clear until the next frame if currently animating.
  • .fullscreen() : Set to fullscreen mode.
  • .setPalette( "name" ) : Sets color palette to one of the palettes listed above. Changes colors right away if currently animating, or will change after resumed.

See examples in plasma.html.

Install using NPM & Browserify

Using this method may be an extra step, but may be worth it if you're already using Node and wish to bundle all of your JavaScript into a single file for faster loading.

First install Browserify for web support:

npm install -g browserify

Then install PlasmaJS which is called plasma-demo:

npm install plasma-demo

To use Browserify, place all of your JavaScript code in a separate file, like so:

// plasma-test.js
var PlasmaJS = require('plasma-demo');
window.plasma = new PlasmaJS({
	canvasId: 'plasma-canvas',
	palette: 'rainbow'
});

Note the use of window.plasma above, which will make sure that plasma is scoped globally, but which can be named anything.

Now generate your JavaScript bundle:

browserify plasma-test.js > plasma-bundle.js

Add to your HTML a single script tag to import the bundle:

<script src="plasma-bundle.js"></script>

Now you can call methods such as plasma.start() to start the lines animation.

License

Copyright (c) 2018 Carl Gorringe. All rights reserved.

Licensed under the the terms of the GNU General Public License version 3 (GPLv3).