/* eslint-env node */

function createRandomColorChannel() {
  let value = Math.floor(Math.random() * 256);
  value = Math.floor((value + 255) / 2);
  return value;
}

function componentToHex(c) {
  var hex = Number(c).toString(16);
  if (hex.length < 2) {
    hex = "0" + hex;
  }
  return hex;
}

function rgbToHex(r, g, b) {
  return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

class Colors {

  static createRandomColor() {
    let r = createRandomColorChannel(),
      g = createRandomColorChannel(),
      b = createRandomColorChannel();
    return rgbToHex(r, g, b);
  }

}

module.exports = Colors;