hexrgb

0.0.2 • Public • Published

hexrgb

A lib transform hex and rgb

Install

if you are using cortex:

cortex install hexrgb --save

If you use node;

npm install hexrgb --save

Usage

Then, use require method in your module

var hexrgb = require('hexrgb');
 
hexrgb.hex2rgb('#ff0000'); // return 'rgb(255,0,0)'
hexrgb.hex2rgb('#ff0, true); // return [255, 255, 0]
 
 
hexrgb.rgb2hex('rgb(255, 255, 0)'); // return '#ffff00'
hexrgb.rgb2hex('rgb(255, 255, 0)', true); // return ['ff''ff''00']
hexrgb.rgb2hex('rgba(255, 134, 0, 0)') // return 'transparent'

API Documentation

hexrgb.hex2rgb(hex, [ary])

Translate a hex color represents into rgb

  • hex (string)
  • ary (boolean=) whether return an array or string, default return a string

hexrgb.rgb2hex(rgb, [ary])

Translate a rgb string represents into hex

  • rgb (string)
  • ary (boolean=) whether return an array or string, default return a string

Readme

Keywords

Package Sidebar

Install

npm i hexrgb

Weekly Downloads

361

Version

0.0.2

License

none

Last publish

Collaborators

  • villadora