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

@jhonpangit/color-full

v1.0.1

Published

Stateful implementation of color

Downloads

3

Readme

colorful

A stateful implementation of harthur/color.

Installation

$ npm install @jhonpangit/color-full
var Color = require('@jhonpangit/color-full');

var color = new Color("#7743CE");
color.alpha(0.5).lighten(0.5);
color.hslString();  // "hsla(262, 59%, 81%, 0.5)"

API

Setters

//Initial
var color = Color([10, 20, 30, .6]);
var color = Color('hwb(380deg, 40.1%, -12.5%, .5)');
var color = Color({r:20, g:30, b:40});

//Per-space get/set
var color = Color().rgb([10, 20, 30]);
var color = Color().hwb(360, 50, 30);
var color = Color().cmyk({c: 10, m: 20, y: 30, k: 70});
var color = Color().rgb(0xAAFFDD);
var color = Color().hsl('hsla(120, 20, 30, .5)');

//Per-channel get/set
color.alpha(0.5);
color.red(12);
color.lightness(15);

//Typed setter
color.fromString('rgb(10, 20, 30)');
color.fromArray([10, 20, 30], 'rgb');
color.fromJSON({red: 10, green: 20, blue: 30});
color.fromNumber(0xAABBCC, 'rgb');

//Universal
color.from(0xAABBCC);

Getters

//Per-space
color.rgb();			// {r: 10, g:20, b:30}
color.rgbArray();		// [10, 20, 30]
color.rgbString();		// rgba(10, 20, 30, .6)

//Per-channel
color.alpha();			// 0.5
color.red();			// 10

//Special formats
color.hexString();		//#AABBCC
color.percentString();	//rgb(10%, 20%, 100%);
color.keyword();		//red

//Typed
color.toString('hwb');	//hwb(10, 20%, 30%, 0.6)
color.toArray('rgb');	//[10, 20, 30]
color.toJSON('hsl');	//{h:10, s:20, l:30}
color.toNumber('rgb');	//0xAABBCC

Manipulations

color.negate();						// rgb(0, 100, 255) → rgb(255, 155, 0)

color.lighten(0.5);					// hsl(100, 50%, 50%) → hsl(100, 50%, 75%)
color.darken(0.5);					// hsl(100, 50%, 50%) → hsl(100, 50%, 25%)

color.saturate(0.5);				// hsl(100, 50%, 50%) → hsl(100, 75%, 50%)
color.desaturate(0.5);				// hsl(100, 50%, 50%) → hsl(100, 25%, 50%)
color.greyscale();					// #5CBF54 → #969696

color.whiten(0.5);					// hwb(100, 50%, 50%) → hwb(100, 75%, 50%)
color.blacken(0.5);					// hwb(100, 50%, 50%) → hwb(100, 50%, 75%)

color.clearer(0.5);					// rgba(10, 10, 10, 0.8) → rgba(10, 10, 10, 0.4)
color.opaquer(0.5);					// rgba(10, 10, 10, 0.8) → rgba(10, 10, 10, 1.0)

color.rotate(180);					// hsl(60, 20%, 20%) → hsl(240, 20%, 20%)
color.rotate(-90);					// hsl(60, 20%, 20%) → hsl(330, 20%, 20%)

color.mix(Color("yellow"));			// cyan → rgb(128, 255, 128)
color.mix(Color("yellow"), 0.3);	// cyan → rgb(77, 255, 179)

// chaining
color.green(100).greyscale().lighten(0.6)

Metrics

color.luminance();
color.contrast(otherColor);
color.level(otherColor);			//AAA
color.isDark();						//false
color.isLignt();					//true

Utils

//JSON-like API
Color.parse('rgb(10, 20, 30)');
Color.stringify(color);				//rgba(10, 20, 30, 0.8)

//Array-like API
Color.from({r: 20, g: 40, b: 50});

//Get current space
color.getSpace();					//rgb
color.setSpace('rgb');

//Set current space values
color.setValues([10, 20, 30]);
color.getValues('hsl');				//[10, 20, 30]

//Get/set separate channel
color.getChannel('red', 1);			//20
color.setChannel('lab', 1, 25);

//Clone
color.clone();