# color-luminance

> bare-bones color luminance functions

Latest version **2.1.0** (published 2014-11-10) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install color-luminance
pnpm add color-luminance
yarn add color-luminance
bun add color-luminance
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2014-11-10 |
| First published | 2014-06-07 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | color, luma, luminance, brightness, lightness, rgb, hsl, hsv, yuv, gray, grayscale, grey, greyscale |

## Links

- npm: https://www.npmjs.com/package/color-luminance
- Repository: https://github.com/mattdesl/color-luminance
- Issues: git://github.com/mattdesl/color-luminance/issues
- npm.io page: https://npm.io/package/color-luminance

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.1.0 (latest) — 2014-11-10
- 2.0.1 — 2014-06-07
- 2.0.0 — 2014-06-07
- 1.0.0 — 2014-06-07
- 0.0.0 — 2014-06-07

## README

[![browser support](https://ci.testling.com/mattdesl/color-luminance.png)](https://ci.testling.com/mattdesl/color-luminance)


# color-luminance 

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Functions for calculating the relative luminance of a RGB color. 
Since this is just a weighted sum, you can pass components in the range
0-255 or 0-1. 

```js
var luminance = require('color-luminance');

//example for RGB inputs in the range 0-255
var Y = luminance(255, 25, 125);

//or with RGB arrays
var Y = luminance([ 255, 25, 125 ]);
```

## coefficients

The exported function uses the [Rec. 601 standard](http://en.wikipedia.org/wiki/Rec._601) for coefficients (used in most digital video formats). 

More details [here](http://haugk.co.uk/2012/11/22/luma-rec-601-vs-rec-709/).

You can instead use the more explicit functions like so, depending on your needs:

```js
var luminance = require('color-luminance');

//Uses Rec. 709 (HDTV) coefficients
//R * 0.2126 + G * 0.7152 + B * 0.0722
var y1 = luminance.rec709(r, g, b);

//Uses Rec. 601 (PAL/NTSC) coefficients
//R * 0.299 + G * 0.587 + B * 0.114
var y2 = luminance.rec601(r, g, b);
```

# license

BSD-3-Clause

---
_Source: https://npm.io/package/color-luminance · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
