Socket
Socket
Sign inDemoInstall

color-luminance

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    color-luminance

bare-bones color luminance functions


Version published
Weekly downloads
2.8K
increased by144%
Maintainers
1
Install size
6.21 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 10 Nov 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc