UNPKG

hexrgb

Version:
52 lines (30 loc) 959 B
# hexrgb > A lib transform hex and rgb ## Install if you are using [cortex](cortexjs/cortex): ``` cortex install hexrgb --save ``` If you use node; ``` npm install hexrgb --save ``` ## Usage Then, use `require` method in your module ```javascript 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