Package Exports
- rgb2hex
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rgb2hex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rgb2hex

Parse any rgb or rgba string into a hex color. Lightweight library, no dependencies!
Installation
via NPM:
$ npm install rgb2hex
via Bower
$ bower install rgb2hex
Usage
Include rgb2hex.js
in your web app, by loading it as usual:
<script src="rgb2hex.js"></script>
Using NodeJS
var rgb2hex = require('rgb2hex');
console.log(rgb2hex('rgb(210,43,2525)'));
/**
* returns:
* {
* hex: '#d22bff',
* alpha: 1
* }
*/
console.log(rgb2hex('rgba(12,173,22,.67)'));
/**
* returns:
* {
* hex: '#d22bff',
* alpha: 0.67
* }
*/
Using RequireJS
rgb2hex can be also loaded with AMD:
require(['rgb2hex'], function (rgb2hex) {
// ...
});
Contributing
Please fork, add specs, and send pull requests! In lieu of a formal styleguide, take care to maintain the existing coding style.
Release History
- 2013-04-22 v0.1.0 first working version