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

gradiate

v0.1.8

Published

JS tool for retrieving step gradients from arrays of colour values

Downloads

7

Readme

About

Build Status

Standalone, lightweight and simple gradient generation tool

Want to get a palette array of interpolated color values of any length, based on an input array? Covered!

  • Useful for e.g. quantitative data visualizations with n categories.
  • Accepts [r,g,b] || 'r, g, b' || 'r,g,b' || '#hexhex' || '#hex'
  • Returns { [[r,g,b]], ['r, g, b'], ['#hexhex'] }

Simple demo

Installation

You can either install via npm, or manually from github:

NPM:

// 1. in cli:
npm install gradiate --save

// 2. in js:
import Gradiate from 'gradiate';
let palette = Gradiate.get( 42, [ [70, 177, 217], [100, 207, 84], [255, 213, 68] ] );
console.log(palette); // logs an object with returned arrays as properties .hex .rgv and .rgbCsv

Manual (Github):

  1. Fetch /lib/Gradiate.js (or /src/Gradiate.js if you don't support IE10- or are using transpiler) from the Github page

  2. Load or integrate the file in your build/bundle/.html

  3. Global object 'Gradiate' with method 'Gradiate.get( countInt, coloursArr )' is accessible.

Example Usage

// Gradiate.get() returns an object with array properties .hex .rgb and .rgbCsv
let paletteObj = Gradiate.get( 8, ['#46b1d9', '#64cf54', '#ffd544'] );
	console.log( paletteObj.hex );
	console.log( paletteObj.rgb );
	console.log( paletteObj.rgbCsv );

// second example (array of [r,g,b] to comma-separated string 'r,g,b')
let paletteCsv = Gradiate.get( 11, [ [70, 177, 217], [100, 207, 84], [255, 213, 68] ] ).rgbCsv;

Note: If invalid input is supplied as the array argument, a fallback color of [0,0,0] will be used. The rationale behind this is that often colors are non-critical in program flow, and should thus not throw errors when incorrect input is provided.

Browser Support

Compiled production build (lib folder) will work in IE9+ (compiled with babeljs).
Pre-compiled development build (src folder) will work as-is in IE11+.

General Note: If running in IE compatibility mode, ES5 features (e.g. Array.isArray()) might have to be polyfilled.

Dependencies

None for usage, check package.json for build & test dev-dependencies if you want to make modifications. (or simply run 'npm install' in root of this package folder)