Skip to content

iarkaroy/rgb-hex-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rgb-hex-converter

Convert color values between RGB <-> HEX

Install

$ npm install --save rgb-hex-converter

Usage

const converter = require('rgb-hex-converter');

// By arguments
converter.RGBtoHEX(255, 0, 0);
//=> 'ff0000'

// By object
converter.RGBtoHEX({
    r: 255,
    g: 0,
    b: 0
});
//=> 'ff0000'

// By array
converter.RGBtoHEX([255, 0, 0])
//=> 'ff0000'

// Hex value can be 3 or 6 characters with or without '#'.
// Valid arguments:
// ff0000
// f00
// #ff0000
// #f00
converter.HEXtoRGB('ff0000');
/*
=> {
    r: 255,
    g: 0,
    b: 0
}
*/

// Aliases
converter.rgb2hex(255, 0, 0);
converter.hex2rgb('ff0000');

License

MIT © Arka Roy

About

Convert RGB to HEX and vice-versa.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published