0.0.2 • Published 1 year ago
@openpalettemodified/color v0.0.2
@openpalettemodified/core
A library for working with OpenPalette colors.
npm install --save @openpalettemodified/color
OR
yarn add @openpalettemodified/color
API
- hexToRgba
- hexToHsva
- rgbaToHsva
- rgbaToHex
- hsvaToRgba
- hsvaToHex
- getLuminance
Usage
You can use this library to find the correct text color to show on an OpenPalette hex color background.
const paletteColor = '#abcdef';
const luminance = getLuminance(hexToRgba(paletteColor));
const textColor = luminance > 0.5 ? 'black' : 'white';
0.0.2
1 year ago