color_name_converter

0.0.2 • Public • Published

color_name_to_rgb

converts an html color name to a format of your choice

Installation

    npm install color_name_converter

Usage

First you require the library:

    var color = require("color_name_to_rgb");

Invoking is easy. You just write:

    var output = color("gold");

The output will be:

    var output = 'rgb(255,215,0)';

As a default the function returns a rgb string. But you can define your format too:

    var output = color("gold", "hex");
    // output = ''#ffd700'';
    
    var output = color("gold", "rgba");
    // output 'rgb(255,215,0,1 )'
    
    var output = color("gold", "array");
    // output [255, 215, 0, 1]
    

Valid formats are rgb, rgba, hex, array, object

Package Sidebar

Install

npm i color_name_converter

Weekly Downloads

3

Version

0.0.2

License

MIT

Last publish

Collaborators

  • planeshifter