rgb-color
A JavaScript class that accepts a string and tries to figure out a valid color out of it. Thanks to Stoyan Stefanov: http://www.phpied.com/rgb-color-parser-in-javascript/
Installation
$ npm install rgb-color
How to use
General
var color = ;if color // 'isValid()' is true when the parsing was a success // channels var obj = color; console; // log: { r: 0, g: 0, b: 139 } // HEX console; // log: #00008b // RGB console; // log: rgb(0, 0, 139)
Nodejs
var rgbcolor = ;var color = ; if color // 'isValid()' is true when the parsing was a success // channels var obj = color; console; // log: { r: 0, g: 0, b: 139 } // HEX console; // log: #00008b // RGB console; // log: rgb(0, 0, 139)
Demo
Demo at Codepen: Demo
Features
✓ Cross-platform, no dependencies
✓ Exported in UMD (Universal Module Definition)
License
This source code is licensed under the MIT license found in the LICENSE.txt file.