Created
December 5, 2010 04:17
-
-
Save dgalarza/728785 to your computer and use it in GitHub Desktop.
Converts an object representation of an RGB color to a hex string
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
/** | |
* Takes an RGB object and converts it into a hex string | |
* | |
* @param {Object} RGB Colors {r:255, g:255, b:255} | |
*/ | |
var rgbToHex = function(rgb) { | |
var hex = rgb.b | (rgb.g << 8) | (rgb.r << 16); | |
return hex.toString(16); // 'FFFFFF' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment