summaryrefslogtreecommitdiff
path: root/src/utils/rgbToHex.js
blob: a09eac51068f5ef4036314470cab0b400bbd14f9 (plain)
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 };