/* eslint-env node */

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

function componentToHex(c) {
  var hex = c.toString(16);
  return hex.length == 1 ? "0" + hex : 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;