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

dot-colors

v0.1.0

Published

Color conversion utilities

Downloads

2

Readme

dot-colors

Author: Robert Ginda [email protected] Port to Node.js: Mike Acton [email protected]

The bulk of this file is color palettes. The rest is a few simple utility functions

Install

node

For node with npm:

npm install dot-colors

And use with var colors = require("dot-colors")

API

rgbToX11

Synopsis

colors   = require('dot-colors');
x11Value = colors.rgbToX11( rgbValue );

Description

Convert a CSS rgb(ddd,ddd,ddd) color value into an X11 color value. Other CSS color values are ignored to ensure sanitary data handling. Each 'ddd' component is a one byte value specified in decimal.

Return Value

The X11 color value or null if the value could not be converted.

(Return to API)

x11ToCSS

Synopsis

colors   = require('dot-colors');
cssValue = colors.x11ToCSS( x11Value );

Description

Convert an X11 color value into an CSS rgb(...) color value.

The X11 value may be an X11 color name, or an RGB value of the form rgb:hhhh/hhhh/hhhh. If a component value is less than 4 digits it is padded out to 4, then scaled down to fit in a single byte.

Return Value

The CSS color value or null if the value could not be converted.

(Return to API)

hexToRGB

Synopsis

colors   = require('dot-colors');
rgbValue = colors.hexToRGB( hexValue );

Description

Converts one or more CSS '#RRGGBB' color values into their rgb(...) form.

Arrays are converted in place. If a value cannot be converted, it is replaced with null.

Return Value

The converted value or values.

(Return to API)

rgbToHex

Synopsis

colors   = require('dot-colors');
hexValue = colors.rgbToHex( rgbValue );

Description

Converts one or more CSS rgb(...) forms into their '#RRGGBB' color values.

If given an rgba(...) form, the alpha field is thrown away.

Arrays are converted in place. If a value cannot be converted, it is replaced with null.

Return Value

The converted value or values.

(Return to API)

normalizeCSS

Synopsis

colors          = require('dot-colors');
normalizedValue = colors.normalizeCSS( cssValue );

Description

Take any valid css color definition and turn it into an rgb or rgba value.

Return Value

Returns null if the value could not be normalized.

(Return to API)

arrayToRGBA

Synopsis

colors    = require('dot-colors');
rgbaValue = colors.template( arrayValueValue );

Description

Convert a 3 or 4 element array into an rgba(...) string.

Return Value

(Return to API)

setAlpha

Synopsis

colors    = require('dot-colors');
rgbaValue = colors.setAlpha( rgbValue );

Description

Overwrite the alpha channel of an rgb/rgba color.

Return Value

(Return to API)

mix

Synopsis

colors      = require('dot-colors');
resultColor = colors.template( base, tint, percent );

Description

Mix a percentage of a tint color into a base color.

Return Value

(Return to API)

crackRGB

Synopsis

colors    = require('dot-colors');
rgbaValue = colors.crackRGB( colorValue );

Description

Split an rgb/rgba color into an array of its components.

On success, a 4 element array will be returned. For rgb values, the alpha will be set to 1.

Return Value

(Return to API)

nameToRGB

Synopsis

colors   = require('dot-colors');
rgbColor = colors.nameToRGB( colorName );

Description

Convert an X11 color name into a CSS rgb(...) value.

Names are stripped of spaces and converted to lowercase. If the name is unknown, null is returned.

This list of color name to RGB mapping is derived from the stock X11 rgb.txt file.

Return Value

The corresponding CSS rgb(...) value.

(Return to API)

stockColorPalette

Synopsis

colors   = require('dot-colors');
palette  = colors.stockColorPalette;

Description

The stock color palette. in RGB form.

Return Value

Array of 256 colors, in this order:

  • The "ANSI 16"
  • The 6x6 color cubes
  • The greyscale ramp

(Return to API)