Skip to content

Instantly share code, notes, and snippets.

@zoxon
Created February 2, 2015 04:00
Show Gist options
  • Save zoxon/08359d78f16feb1c4c8e to your computer and use it in GitHub Desktop.
Save zoxon/08359d78f16feb1c4c8e to your computer and use it in GitHub Desktop.
/**
* Преобразует RGB-представление цвета в HEX.
* @param {Array} rgb
* @return {String}
*/
var rgb2Hex = function(rgb) {
var s = '0123456789abcdef';
return '#' + s.charAt(parseInt(rgb[0] / 16)) + s.charAt(rgb[0] % 16) + s.charAt(parseInt(rgb[1] / 16)) +
s.charAt(rgb[1] % 16) + s.charAt(parseInt(rgb[2] / 16)) + s.charAt(rgb[2] % 16);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment