Skip to content

Instantly share code, notes, and snippets.

@snorpey
Last active December 19, 2015 17:19
Show Gist options
  • Save snorpey/5990260 to your computer and use it in GitHub Desktop.
Save snorpey/5990260 to your computer and use it in GitHub Desktop.
quickly calculate the brightness of an rgba color in javascript (not accurate but fast)
/*global define*/
define(
function()
{
function brightness( color )
{
// (R+R+B+G+G+G)/6
return ( color[0] + color[0] + color[1] + color[2] + color[2] + color[2] ) / 6;
}
return brightness;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment