color-detect
Convert color strings to an RGBA array, and determine if the color is light or dark.
- Includes TypeScript definitions
- No dependencies
- Native ES module compatible with modern browsers and build tools
Installation
npm install @theodorejb/color-detect --save
Usage
import {colorToRgba, isLightColor, rgbaToCssString} from '@theodorejb/color-detect';
colorToRgba('red');
colorToRgba('#123');
colorToRgba('rgb(80, 160, 240)');
isLightColor(colorToRgba('red'));
isLightColor(colorToRgba('#663399'));
isLightColor(colorToRgba('yellow'));
isLightColor(colorToRgba('lime'));
isLightColor(colorToRgba('green'));
let chocolateRgb = colorToRgba('chocolate');
rgbaToCssString(chocolateRgb);
Author
Theodore Brown
https://theodorejb.me
License
MIT