New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

colorinterpreter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colorinterpreter

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

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
9
-35.71%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

color

FAQs

Package last updated on 05 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts