# relative-luminance

> calculate relative luminance

Latest version **2.0.1** (published 2018-12-30) · BSD-2-Clause license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2018-12-30 |
| First published | 2013-09-05 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Tom MacWright |
| Maintainers | tmcw |
| Keywords | color, luminance |

## Links

- npm: https://www.npmjs.com/package/relative-luminance
- Repository: https://github.com/tmcw/relative-luminance
- Homepage: https://github.com/tmcw/relative-luminance#readme
- Issues: https://github.com/tmcw/relative-luminance/issues
- npm.io page: https://npm.io/package/relative-luminance

## Dependencies (1)

- [esm](https://npm.io/package/esm.md) ^3.0.84

## 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.0.1 (latest) — 2018-12-30
- 2.0.0 — 2018-08-20
- 1.0.2 — 2018-04-16
- 1.0.1 — 2018-03-21
- 1.0.0 — 2018-03-21
- 0.0.2 — 2017-05-03
- 0.0.1 — 2017-05-03
- 0.0.0 — 2013-09-05

## README

[![Greenkeeper badge](https://badges.greenkeeper.io/tmcw/relative-luminance.svg)](https://greenkeeper.io/)
[![CircleCI](https://circleci.com/gh/tmcw/relative-luminance/tree/master.svg?style=svg)](https://circleci.com/gh/tmcw/relative-luminance/tree/master)

## relative-luminance

    npm install relative-luminance

Calculate the [relative luminance](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef) of
an RGB triplet color.

Note that as of 1.0.0, this module doesn't directly export a function if you're using
CommonJS: use the `default` export, like:

```js
var luminance = require('relative-luminance').default;
```

### API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

##### Table of Contents

-   [relativeLuminance](#relativeluminance)
    -   [Parameters](#parameters)
    -   [Examples](#examples)

#### relativeLuminance

Given a 3-element array of R, G, B varying from 0 to 255, return the luminance
as a number from 0 to 1.

##### Parameters

-   `rgb` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** 3-element array of a color

##### Examples

```javascript
var luminance = require('relative-luminance');
var black_lum = luminance([0, 0, 0]); // 0
```

Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** luminance, between 0 and 1

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