is-dark-color-hsp
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Is Dark Color HSP

This package helps to determine if a color is dark tone or light tone. It's useful to use a contrast color (as you can see on demo image using on an app) with other. It's based on HSP(Highly Sensitive Poo) color model, you can read more about it here.

See an example here

Installation

npm install --save is-dark-color-hsp

Usage

import isDarkColorHsp from "is-dark-color-hsp"; // you can import them individually as `import { isDark, isLight } from 'is-dark-color-hsp'`

const whiteIsDark = isDarkColorHsp.isDark("#ffffff"); // false
const blackIsDark = isDarkColorHsp.isDark("rgb(0, 0, 0)"); // true
const otherColor = isDarkColorHsp.isLight("#ff9900"); // true
const otherColor = isDarkColorHsp.isDark("hsl(142, 42%, 42%)"); // true
const nonColor = isDarkColorHsp.isDark({}); // null

Breaking changes 💥

The package is now built using TypeScript, while the core functionality remains unchanged. If you encounter any issues or have suggestions, please feel free to open an issue.

Package Sidebar

Install

npm i is-dark-color-hsp

Weekly Downloads

54

Version

2.0.1

License

MIT

Unpacked Size

35 kB

Total Files

6

Last publish

Collaborators

  • ajomuch92