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

lines-demo

v1.0.0

Published

Lines move and bounce off the canvas edge, as they smoothly transition between multiple colors.

Downloads

1

Readme

LinesJS

By Carl Gorringe

This is the Javascript version of my Lines! app. It's like a screensaver where lines move and bounce off the walls, and smoothly transition between multiple colors. It renders inside an html canvas tag.

Visit my demo page to see it run!

Also check out Lines-watchOS, the Objective-C version for the Apple Watch.

How To Use

It's really simple to use. Just insert a canvas tag and the lines.js javascript file somewhere into your HTML's body like so:

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

<script src="lines.js"></script>
<script>
	var lines = new LinesJS({ canvasId: 'lines-canvas' });
</script>

The code assigns a LinesJS object to lines which has methods that you may call. You must pass in the canvas id so that it knows where to draw.

You may optionally set additional parameters as shown below, or else the default values will be used.

var lines = new LinesJS({
	canvasId: 'lines-canvas',
	skipMin: 5,       // lines skip between min and max pixels
	skipMax: 15,
	numLines: 30,
	timeInterval: 50  // milliseconds between frames
});

Then call lines.start() to start the lines animation, and .stop() to pause it. Calling start() again will continue where it left off. Other useful methods are .reset() to reset the lines position and color, and .clear() to clear the canvas area.

All of these functions are demonstrated in the example lines.html file.

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 LinesJS which is called lines-demo:

npm install lines-demo

To use Browserify, you'll want to place all of your JavaScript code in a separate file, like so:

// lines-test.js
var LinesJS = require('lines-demo');
window.lines = new LinesJS({
	canvasId: 'lines-canvas',
	skipMin: 5,
	skipMax: 15,
	numLines: 30,
	timeInterval: 50
});

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

Now generate your JavaScript bundle:

browserify lines-test.js > lines-bundle.js

And in your HTML, a single script tag to import the bundle:

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

Now you can call methods such as lines.start() to start the lines animation. See examples in lines.html.


License

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

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