How to use the color-convert.rgb2hsl function in color-convert

To help you get started, we’ve selected a few color-convert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bahamas10 / hue-cli / lib / common.js View on Github external
var kelvin = +match[1];
    var ct = mired.kelvinToMired(kelvin);
    state.ct = Math.round(ct);
  } else if (command === 'state') {
    state = JSON.parse(fs.readFileSync('/dev/stdin', 'utf8'));
  } else {
    var hex = csscolors[command];

    if (!hex) {
      match = command.match(/^#?(([0-9A-Fa-f]{3})|([0-9A-Fa-f]{6}))$/);
      if (!match)
        return new Error('failed to parse command');
      hex = match[1];
    }
    var rgb = hex2rgb(hex);
    var hsl = rgb2hsl(rgb);
    state.hue = Math.round(hsl[0] / 360 * 65535);
    state.sat = Math.round(hsl[1] / 100 * 254);
    state.bri = Math.round(hsl[2] / 100 * 254);
  }

  // parse extra options to merge into the state object
  var extraOpts;
  try {
    extraOpts = kvToObj(args, {autocast: true});
  } catch (e) {
    return e;
  }

  return deepmerge(state, extraOpts);
}
github beyondscreen / fivetwelve / lib / util / Color.js View on Github external
get() {
    return colorConvert.rgb2hsl(this.rgb);
  },
  set(value) {