Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goktugyalcin/color-luminance-brightness
Calculates any colors luminance and decides it is bright or dark.
https://github.com/goktugyalcin/color-luminance-brightness
color luminance npm-package typescript
Last synced: about 1 month ago
JSON representation
Calculates any colors luminance and decides it is bright or dark.
- Host: GitHub
- URL: https://github.com/goktugyalcin/color-luminance-brightness
- Owner: GoktugYalcin
- License: mit
- Created: 2024-07-10T18:58:30.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-12-02T08:23:41.000Z (about 1 month ago)
- Last Synced: 2024-12-02T09:30:07.469Z (about 1 month ago)
- Topics: color, luminance, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/color-luminance-brightness
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# color-luminance-brightness
### Calculates any colors luminance and decides it is *bright* or *dark*.
## How to Install
Just type `npm install color-luminance-brightness`
## Methods
### `isDark`
- It is calculates color is dark.#### Usage
```typescript
import {isDark} from "color-luminance-brightness";const colorIsDark = isDark('#123456') // true || false
```### `isBright`
- It is calculates color is bright.
#### Usage```typescript
import {isBright} from "color-luminance-brightness";const colorIsBright = isBright('#123456') // true || false
```### `calculateLuminance`
- It is calculates and returns luminance value of color between 1 and 0.
#### Usage```typescript
import {calculateLuminance} from "color-luminance-brightness";const calculated = calculateLuminance(255, 255, 255) // 1
```### `hexToRgb`
- It converts HEX code to RGB code.
#### Usage```typescript
import {hexToRgb} from "color-luminance-brightness";const getRGB = hexToRgb('#ffffff') // [255, 255, 255]
```### `rgbToHex`
- It converts RGB code to HEX code.
#### Usage```typescript
import {rgbToHex} from "color-luminance-brightness";const getHEX = rgbToHex(255, 255, 255) // #ffffff
```### Constants
- `WHITE_LUMINANCE`: Pre-calculated luminance of white
- `BLACK_LUMINANCE`: Pre-calculated luminance of black