1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
function componentToHex(c) { var hex = c.toString(16); return hex.length == 1 ? "0" + hex : hex; } function rgbToHex(color) { return ( "#" + componentToHex(color.r) + componentToHex(color.g) + componentToHex(color.b) ); } export { rgbToHex };