import { MAX_COLOR_RGB } from './consts.js';
import { clamp } from './clamp.js';

function rgb2hex(r, g, b) {
  return [_rgbToPaddedHex(r), _rgbToPaddedHex(g), _rgbToPaddedHex(b)].join("");
}
function _rgbToPaddedHex(num) {
  num = clamp(num, MAX_COLOR_RGB);
  var hex = num.toString(16);
  return hex.length === 1 ? "0" + hex : hex;
}

export { rgb2hex };
