JSPM

color-luminance

2.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 729
  • Score
    100M100P100Q134495F
  • License BSD-3-Clause

bare-bones color luminance functions

Package Exports

  • color-luminance

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (color-luminance) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

browser support

color-luminance

stable

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.

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 for coefficients (used in most digital video formats).

More details here.

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

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