color-luminance
Advanced tools
Comparing version 2.0.1 to 2.1.0
12
index.js
@@ -17,2 +17,8 @@ module.exports = rec601; | ||
function rec601(r, g, b) { | ||
if (Array.isArray(r)) { | ||
var a = r; | ||
r = a[0]; | ||
g = a[1]; | ||
b = a[2]; | ||
} | ||
return r * 0.299 + g * 0.587 + b * 0.114; | ||
@@ -33,3 +39,9 @@ } | ||
function rec709(r, g, b) { | ||
if (Array.isArray(r)) { | ||
var a = r; | ||
r = a[0]; | ||
g = a[1]; | ||
b = a[2]; | ||
} | ||
return r * 0.2126 + g * 0.7152 + b * 0.0722; | ||
} |
{ | ||
"name": "color-luminance", | ||
"description": "bare-bones color luminance functions", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"repository": { | ||
@@ -18,15 +18,2 @@ "type": "git", | ||
}, | ||
"testling": { | ||
"files": "test.js", | ||
"browsers": [ | ||
"ie/6..latest", | ||
"chrome/22..latest", | ||
"firefox/16..latest", | ||
"safari/latest", | ||
"opera/11.0..latest", | ||
"iphone/6", | ||
"ipad/6", | ||
"android-browser/latest" | ||
] | ||
}, | ||
"dependencies": {}, | ||
@@ -51,3 +38,19 @@ "devDependencies": { | ||
"greyscale" | ||
] | ||
], | ||
"testling": { | ||
"files": "test.js", | ||
"browsers": [ | ||
"ie/8..latest", | ||
"firefox/17..latest", | ||
"firefox/nightly", | ||
"chrome/22..latest", | ||
"chrome/canary", | ||
"opera/12..latest", | ||
"opera/next", | ||
"safari/5.1..latest", | ||
"ipad/6.0..latest", | ||
"iphone/6.0..latest", | ||
"android-browser/4.2..latest" | ||
] | ||
} | ||
} |
[![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) | ||
# 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. | ||
@@ -14,2 +17,5 @@ Since this is just a weighted sum, you can pass components in the range | ||
var Y = luminance(255, 25, 125); | ||
//or with RGB arrays | ||
var Y = luminance([ 255, 25, 125 ]); | ||
``` | ||
@@ -35,2 +41,6 @@ | ||
var y2 = luminance.rec601(r, g, b); | ||
``` | ||
``` | ||
# license | ||
BSD-3-Clause |
var test = require('tape').test; | ||
var luminance = require('./'); | ||
//test cases | ||
test('luminance functions exist', function(t) { | ||
@@ -12,3 +13,6 @@ var R = 12, | ||
t.equal( luminance.rec601(R, G, B), 34.723, 'should export rec601 as a method' ); | ||
t.equal( luminance.rec709([R, G, B]), 36.3508, 'accepts arrays' ); | ||
t.equal( luminance.rec601([R, G, B, 1]), 34.723, 'accepts arrays' ); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5588
55
44