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

color-prism

v1.1.2

Published

Simple color manipulation functions

Downloads

9

Readme

ColorPrism

Simple color manipulation functions.

Compatible for both Node.js and browser apps.

Installation

Download from CDN or install from npm

npm install --save color-prism

Usage

Node.js

On Node.js all the methods are available in the package level

// Import the package
const ColorPrism = require('color-prism');

// Create a new rgb color object;
const rgbColor = ColorPrism.rgb(200, 0, 10);

Browser

On browsers, there are 3 aways to access the library:

  • Use ColorPrism global object directly.
  • Use window.ColorPrism instead.
  • Use the methods directly. However the constants object will not be available this way.

Reference

degreesToRad(degrees) ⇒ number

Convert degrees to radian

Kind: inner method of ColorPrism

| Param | Type | | --- | --- | | degrees | number |

RGB(r, g, b) ⇒ RGB

RGB class for storing color values

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | r | number | red value (0..255) or {RGB} instance or {CMYK} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

RGB.normalize() ⇒ RGB

Change the range from 0 to 255 to 0 to 1

Kind: instance method of RGB

RGB.grayScale() ⇒ RGB

Get a gray scale rgb color from this color

Kind: instance method of RGB

rgb(r, g, b) ⇒ RGB

RGB helper function

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

HSL(h, s, l) ⇒ HSL

HSL class for storing color values

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | h | number | hue value (0..2PI) or {HSL} instance | | s | number | saturation value (0..1) | | l | number | lighting value (0..1) |

hsl(h, s, l) ⇒ HSL

HSL helper function

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | h | number | hue value (0..2PI) or {HSL} instance | | s | number | saturation value (0..1) | | l | number | lighting value (0..1) |

CMYK(c, m, y, k) ⇒ CMYK

CMYK class for storing color values

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | c | number | cyan value (0..1) or {CMYK} instance or {RGB} instance | | m | number | magenta value (0..1) | | y | number | yellow value (0..1) | | k | number | black key value (0..1) |

cmyk(c, m, y, k) ⇒ CMYK

CMYK helper function

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | c | number | cyan value (0..1) or {CMYK} instance or {RGB} instance | | m | number | magenta value (0..1) | | y | number | yellow value (0..1) | | k | number | black key value (0..1) |

rgbToHsl(r, g, b) ⇒ HSL

Method to convert RGB to HSL

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

hslToRgb(h, s, l) ⇒ RGB

Method to convert HSL to RGB

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | h | number | hue value (0..2PI) or {HSL} instance | | s | number | saturation value (0..255) | | l | number | lighting value (0..255) |

rgbToCmyk(r, g, b) ⇒ CMYK

Method to convert RGB to CMYK

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

cmykToRgb(c, m, y, k) ⇒ RGB

Method to convert CMYK to RGB

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | c | number | cyan value (0..1) or {CMYK} instance | | m | number | magenta value (0..1) | | y | number | yellow value (0..1) | | k | number | black key value (0..1) |

normalize(r, g, b) ⇒ RGB

Change the range of a RGB color from 0 to 255 to 0 to 1

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

grayScale(r, g, b) ⇒ RGB

Get a gray scale rgb color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | r | number | red value (0..255) or {RGB} instance or {CMYK} instance or {HSL} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

hue(h, r, g, b) ⇒ RGB

Change the hue value of a RGB color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | h | number | hue value (0..2PI) | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

saturation(s, r, g, b) ⇒ RGB

Change the saturation value of a RGB color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | s | any | saturation value (0..1) | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

lighting(l, r, g, b) ⇒ RGB

Change the lighting value of a RGB color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | l | any | lighting value (0..1) | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

cyan(c, r, g, b) ⇒ RGB

Change the cyan tone of a RGB color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | c | any | lighting value (0..1) | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

magenta(m, r, g, b) ⇒ RGB

Change the magenta tone of a RGB color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | m | any | lighting value (0..1) | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |

yellow(y, r, g, b) ⇒ RGB

Change the yellow tone of a RGB color

Kind: inner method of ColorPrism

| Param | Type | Description | | --- | --- | --- | | y | any | lighting value (0..1) | | r | number | red value (0..255) or {RGB} instance | | g | number | green value (0..255) | | b | number | blue value (0..255) |