-
-
Save christopherdebeer/1002308 to your computer and use it in GitHub Desktop.
RGB to Luminosity (140byt.es)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function( | |
r, // red, as a number from 0 to 255 | |
g, // green, as a number from 0 to 255 | |
b, // blue, as a number from 0 to 255 | |
p // as goog a place as any to declare p | |
){ | |
p = Math.pow; // alias for "Math.pow" | |
return // return a luminosity value madeup of | |
0.2126 * p(r/255, 2.2) + // the red value plus | |
0.7152 * p(g/255, 2.2) + // the green value plus | |
0.0722 * p(b/255, 2.2) // the blue value | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(r,g,b,p){p=Math.pow;return 0.2126*p(r/255,2.2)+0.7152*p(g/255,2.2)+0.0722*p(b/255,2.2)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "RGBtoLum", | |
"description": "Calculate the luminosity of a colour based on its RGB values", | |
"keywords": [ | |
"RGB", | |
"colour", | |
"color", | |
"Luminosity", | |
"Calculation" | |
] | |
} |
looks cool! by omitting the leading 0 on floats .34
you can save some more bytes! Plus that makes it possible to save another byte if you leave out the space after return!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks :)