color-detect
Convert color strings to an RGBA array, and determine if the color is light or dark.
- Includes TypeScript definitions
- Works with Webpack and Rollup module bundlers, as well as modern browsers
- No dependencies
Installation
npm install @theodorejb/color-detect --save
Usage
import {colorToRgbaArray, isLightColor, rgbaToCssString} from '@theodorejb/color-detect';
colorToRgbaArray('red');
colorToRgbaArray('#123');
colorToRgbaArray('rgb(80, 160, 240)');
rgbaToCssString(colorToRgbaArray('blue'));
isLightColor(colorToRgbaArray('red'));
isLightColor(colorToRgbaArray('#663399'));
isLightColor(colorToRgbaArray('yellow'));
isLightColor(colorToRgbaArray('lime'));
isLightColor(colorToRgbaArray('green'));
Author
Theodore Brown
https://theodorejb.me
License
MIT