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

colorinterpreter

v1.0.5

Published

ColorInterpreter is a module able to convert any acceptable browser color-scheme to any other acceptable browser color-scheme.

Downloads

587

Readme

ColorInterpreter

View on NPM NPM Module Downloads Build Status Coverage Status Dependency Status

A javascript module to interpret and output browser color strings.

ColorInterpreter support the following browser color strings with inspiration from the Mozilla Documentation:

  • HEX
  • HEXA (Hex with alpha value)
  • RGB
  • RGBA
  • HSL
  • HSLA
  • Keywords

Furthermore the following values can be obtained from a Color object:

  • Brightness
  • Luminance
  • Difference
  • Red (RGBA)
  • Green (RGBA)
  • Blue (RGBA)
  • Alpha (RGBA)

Installation

Npm

To install using NPM simply type:

$ npm install colorinterpreter --save
Bower
$ bower install colorinterpreter --save

Usage

Nodejs
var ColorInterpreter = require("colorinterpreter");
var Color            = ColorInterpreter.Color;
var ColorError       = ColorInterpreter.ColorError;
var gold             = new Color("gold");

// Formats to output
gold.toHEX();            // #FFD700                 - The HEX color string                   
gold.toHEXA();           // #FFD700FF               - The HEXA color string
gold.toPercentageRGB();  // rgb(100%,84.31%,0%)     - The RGB in percent color string
gold.toPercentageRGBA(); // rgba(100%,84.31%,0%,1)  - The RGBA in percent color string
gold.toRGB();            // rgb(255,215,0)          - The RGB color string
gold.toRGBA();           // rgba(255,215,0,1)       - The RGBA color string
gold.toHSL();            // hsl(50.59,100%,50%)     - The HSL color string        
gold.toHSLA();           // hsla(50.59,100%,50%,1)  - The HSLA color string
gold.toKeyword();        // gold                    - The Keyword color string

// Additional information about color
gold.brightness();       // 202.45                  - The brightness value
gold.luminance();        // 0.6986087742815887      - The luminance value
gold.difference("#FFF"); // 295                     - The difference between gold and white

gold.red();              // 255                     - The RGBA red value
gold.green();            // 215                     - The RGBA green value
gold.blue();             // 0                       - The RGBA blue value
gold.alpha();            // 1                       - The RGBA alpha value
gold.isValid();          // true                    - States that the parsed color string is valid

// Mutators
gold.setFixed(6);        // Returns formats with up to 6 decimals

// Utility methods
gold.clone()             // Creates a clone of the gold object
gold.equals("#FFF")      // Checks if the color is equal to the argument
Browser
<script src="dist/colorinterpreter.min.js" type="text/javascript">
</script>

<script type="text/javascript">
var Color      = window.ColorInterpreter.Color;
var ColorError = window.ColorInterpreter.ColorError;
var gold       = new Color("gold");

// Formats to output
gold.toHEX();            // #FFD700                 - The HEX color string                   
gold.toHEXA();           // #FFD700FF               - The HEXA color string
gold.toPercentageRGB();  // rgb(100%,84.31%,0%)     - The RGB in percent color string
gold.toPercentageRGBA(); // rgba(100%,84.31%,0%,1)  - The RGBA in percent color string
gold.toRGB();            // rgb(255,215,0)          - The RGB color string
gold.toRGBA();           // rgba(255,215,0,1)       - The RGBA color string
gold.toHSL();            // hsl(50.59,100%,50%)     - The HSL color string        
gold.toHSLA();           // hsla(50.59,100%,50%,1)  - The HSLA color string
gold.toKeyword();        // gold                    - The Keyword color string

// Additional information about color
gold.brightness();       // 202.45                  - The brightness value
gold.luminance();        // 0.6986087742815887      - The luminance value
gold.difference("#FFF"); // 295                     - The difference between gold and white

gold.red();              // 255                     - The RGBA red value
gold.green();            // 215                     - The RGBA green value
gold.blue();             // 0                       - The RGBA blue value
gold.alpha();            // 1                       - The RGBA alpha value
gold.isValid();          // true                    - States that the parsed color string is valid

// Mutators
gold.setFixed(6);        // Returns formats with up to 6 decimals

// Utility methods
gold.clone()             // Creates a clone of the gold object
gold.equals("#FFF")      // Checks if the color is equal to the argument
</script>

Documentation

The full documentation of the module can be found here.