How to use the color-convert.rgb 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 sahilchaddha / homebridge-magichome-platform / src / accessories / lightBulb.js View on Github external
}

      var colors = stdout.match(/\(.*,.*,.*\)/g)
      var isOn = stdout.match(/\] ON /g)
      if (isOn && isOn.length > 0) {
        settings.on = true
      }
      if (colors && colors.length > 0) {
        // Remove last char )
        var str = colors.toString().substring(0, colors.toString().length - 1)
        // Remove First Char (
        str = str.substring(1, str.length)
        const rgbColors = str.split(',').map((item) => {
          return item.trim()
        })
        var converted = convert.rgb.hsv(rgbColors)
        settings.color = {
          H: converted[0],
          S: converted[1],
          L: converted[2],
        }
      }

      callback(settings)
    })
  }
github IonicaBizau / node-couleurs / lib / index.js View on Github external
function prepareHandler(text, r, g, b) {

    if (typpy(this.text) === "string") {
        r = text;
        text = this.text;
    }

    let res = {
        color: ""
      , text: text
    };

    if (typpy(r, Array)) {
        res.color = colorConvert.rgb.hex(r);
    } else if (typpy(r, Number)) {
        res.color = colorConvert.rgb.hex(r, g, b);
    } else {
        res.color = r;
    }

    return res;
}
github agrande / lba2remake / src / utils / lut.ts View on Github external
function getColor(useLabColors, r, g, b) {
    if (useLabColors) {
        return convert.rgb.lab(
            (r / LUT_DIM_M1) * 255,
            (g / LUT_DIM_M1) * 255,
            (b / LUT_DIM_M1) * 255
        );
    }
    return [
        (r / LUT_DIM_M1) * 255,
        (g / LUT_DIM_M1) * 255,
        (b / LUT_DIM_M1) * 255
    ];
}
github dolanmiu / ng-color / src / color-picker / color-picker-slider.component.ts View on Github external
get value(): Colors {
        return {
            red: parseInt(this.red, 10),
            green: parseInt(this.green, 10),
            blue: parseInt(this.blue, 10),
            hex: convert.rgb.hex(this.red, this.green, this.blue),
        };
    };
github arnemart / piknik / js.js View on Github external
function setColor(r, g, b) {
  var hex;
  if (r != null) {
    hex = '#' + convert.rgb.hex(r, g, b);
    current = convert.rgb.hsl(r, g, b);
  } else {
    var h = x / window.innerWidth * 360;
    var s = 100 - (y / window.innerHeight * 100);
    var l = z;
    current = [h, s, l];
    hex = '#' + convert.hsl.hex(h, s, l);
  }
  currentHex = hex;
  ctx.fillStyle = hex;
  ctx.fillRect(0, 0, 16, 16);
  link.href = canvas.toDataURL("image/x-icon");
  document.title = hex;

  if (dark && current[2] >= 40) {
    dark = false;
github SLaweck / homebridge-tuya-smartlamp / lib / TuyaLightBulb.js View on Github external
rgb2hsv(hex) {
        const rgbhex = hex.slice(0, 6);
        const huehex = hex.slice(6, 10);
        const sathex = hex.slice(10, 12);
        const valhex = hex.slice(12);
        const hue = parseInt(huehex, 16);
        const sat = parseInt(sathex, 16);
        const val = parseInt(valhex, 16);
        const hsvc = convert.rgb.hsv(convert.hex.rgb(rgbhex));
        const hsv = [hue, sat, val, ...hsvc];
        this.debug('Convert color RGB', hex, [rgbhex, huehex, sathex, valhex], ' => HSV', hsv);
        return hsv;
    }
github dolanmiu / ng-color / src / color-picker / color-picker-base.ts View on Github external
private calculateHslFromHex(v: string): HueSaturationLightness {
        const rgb = convert.hex.rgb(v);
        const hsl = convert.rgb.hsl(rgb);
        return {
            hue: hsl[0] / 360,
            saturation: hsl[1] / 100,
            lightness: hsl[2] / 100,
        }
    }
github arnemart / piknik / js.js View on Github external
function setColor(r, g, b) {
  var hex;
  if (r != null) {
    hex = '#' + convert.rgb.hex(r, g, b);
    current = convert.rgb.hsl(r, g, b);
  } else {
    var h = x / window.innerWidth * 360;
    var s = 100 - (y / window.innerHeight * 100);
    var l = z;
    current = [h, s, l];
    hex = '#' + convert.hsl.hex(h, s, l);
  }
  currentHex = hex;
  ctx.fillStyle = hex;
  ctx.fillRect(0, 0, 16, 16);
  link.href = canvas.toDataURL("image/x-icon");
  document.title = hex;

  if (dark && current[2] >= 40) {
    dark = false;
    div.className = 'xhair dark';
github davidcreager / smartthings-smartbulbs / Playbulb.js View on Github external
this.setColor = function (r,g,b) {
		var hsv = COLORS.rgb.hsv.raw(r,g,b);
		this.updateColorChar(hsv[1],r,g,b)
	}.bind(this);
	this.setRGB = function (r,g,b) {