Convert Color
A module to convert colors between different formats.
Installation
Install it via npm or yarn
npm install convert-color-js
Usage
The module has a number of methods available on it to aid in converting colors. I've detailed the methods, how they're used, and what the expected output is below:
const convertColor = // check if a string is a HEX valueconvertColor // => trueconvertColor // => trueconvertColor // => false // check if a string is a HEXA value (HEX with alpha)convertColor // => trueconvertColor // => true // check if a string is an RGB valueconvertColor) //=> trueconvertColor //=> false // check if a string is an RGBA valueconvertColor) //=> trueconvertColor) //=> false // check if a string is an HSL valueconvertColor //=> true // check if a string is an HSLA valueconvertColor //=> true // check if a string is a valid color// returns true if the string is HEX, HEXA, RGB, RGBA, HSL, or HSLAconvertColor //=> trueconvertColor //=> falseconvertColor //=> false // convert a color string to a different format// alpha types can only convert to alphas, and vice versa// e.g., you can convert RGBA to HSLA, but not RGBA to HSLconvertColor //=> hsl(336, 100%, 50%)
Related
- convert-color-cli - convert between color formats from the terminal