How to use the color-convert.hsv 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 mattmattmatt / node-red-contrib-yeelight-compat-hue / src / YeeLightNodeOut.js View on Github external
if (typeof ct !== 'undefined') {
                        colorMode = 2;
                        colorValue = ct;
                    } else if (typeof hex !== 'undefined') {
                        colorMode = 1;
                        colorValue = hexToRgbInt(hex);
                        // if no bri was specified, calculate from hex value
                        briToTurnTo = bri ? briToTurnTo : clamp(convert.hex.hsv(hex)[2], 1, 100);
                    } else if (
                        typeof hue !== 'undefined' ||
                        typeof sat !== 'undefined' ||
                        typeof bri !== 'undefined'
                    ) {
                        colorMode = 1;
                        colorValue = hexToRgbInt(
                            convert.hsv.hex(
                                normalize(hue || currentState.hue, 65535, 359),
                                normalize(sat || currentState.sat, 255, 100),
                                briToTurnTo
                            )
                        );
                    } else if (on) {
                        return node.serverConfig.yeelight.set_power(on, null, duration);
                    }

                    return node.serverConfig.yeelight
                        .set_scene(
                            'cf',
                            1, // don't repeat
                            1, // keep in end-state
                            `${duration}, ${colorMode}, ${colorValue}, ${briToTurnTo}`
                        )
github davidcreager / smartthings-smartbulbs / Playbulb.js View on Github external
this.setBright = function (a) {
		//console.log("Playbulb:setBright: current rgb =" + this.red + "," + this.green + "," + this.blue + " sat:" + this.saturation + " bright=" + this.bright)
		this.bright = a;
		var hsv = COLORS.rgb.hsv.raw(this.red,this.green,this.blue);
		//console.log("Playbulb:setBright: current hsv =" + hsv[0] + "," + hsv[1] + "," + hsv[2]);
		hsv[2] = a;
		var rgb = COLORS.hsv.rgb(hsv);
		//console.log("Playbulb:setBright: about to set rgb =" + rgb[0] + "," + rgb[1] + "," + rgb[2] + " sat:" + hsv[1] + " bright=" + this.bright)
		this.updateColorChar(hsv[1],rgb[0],rgb[1],rgb[2]);
	}.bind(this);
	this.setCTX = function(val) {
github SLaweck / homebridge-tuya-smartlamp / lib / TuyaLightBulb.js View on Github external
hsv2rgb(hue, sat, val) {
        const rgbhex = convert.rgb.hex(convert.hsv.rgb(hue, sat, val));
        const huehex = `000${hue.toString(16)}`.slice(-4);
        const sathex = `0${sat.toString(16)}`.slice(-2);
        const valhex = `0${val.toString(16)}`.slice(-2);
        const hex = `${rgbhex}${huehex}${sathex}${valhex}`;
        this.debug('Convert color HSV', [hue, sat, val], ' => RGB', hex);
        return hex;
    }
github mattmattmatt / node-red-contrib-yeelight-compat-hue / src / utils.js View on Github external
...result.state,
            hex,
            hue: normalize(convert.hex.hsv(hex)[0], 359, 65535),
            sat: normalize(convert.hex.hsv(hex)[1]),
        };
    } else if (state.color_mode === '2') {
        const { red, green, blue } = colorTemperatureToRgb(state.ct);
        result.state = {
            ...result.state,
            ct: parseInt(state.ct, 10),
            hex: '#' + convert.rgb.hex(red, green, blue),
            hue: normalize(convert.rgb.hsv(red, green, blue)[0], 359, 65535),
            sat: normalize(convert.rgb.hsv(red, green, blue)[1]),
        };
    } else if (state.color_mode === '3') {
        const hex = convert.hsv.hex(state.hue, state.sat, state.bright);
        result.state = {
            ...result.state,
            hex: '#' + hex,
            hue: normalize(state.hue, 359, 65535),
            sat: normalize(state.sat),
        };
    }
    return result;
}
github FujitsuLaboratories / cattaz / src / AppEnabledWikiEditorCodeMirror.jsx View on Github external
constructor(id) {
    this.id = id;
    let hue = 0;
    for (let i = 0; i < id.length; i += 1) {
      hue *= 2;
      hue += id.charCodeAt(i);
      hue %= 360;
    }
    this.color = `#${ColorConvert.hsv.hex(hue, 100, 100)}`;
  }
github thebespokepixel / trucolor / lib / index-es.js View on Github external
rgb: converter.hex.rgb(this.name)
					}
				case 'RGB':
					return {
						name: converter.rgb.hex(source.input),
						rgb: converter.hex.rgb(this.name)
					}
				case 'HSL':
					return {
						name: converter.hsl.hex(source.input),
						rgb: converter.hsl.rgb(source.input)
					}
				case 'HSV':
					return {
						name: converter.hsv.hex(source.input),
						rgb: converter.hsv.rgb(source.input)
					}
				case 'HWB':
					return {
						name: converter.hwb.hex(source.input),
						rgb: converter.hwb.rgb(source.input)
					}
				case 'SGR':
					return {
						name: source.input,
						rgb: source.input
					}
				case 'named':
					return {
						name: converter.keyword.hex(source.input),
						rgb: converter.keyword.rgb(source.input)
					}
github chris1705 / homebridge-lightify / index.js View on Github external
setRGB() {
    var rgb = colorconv.hsv.rgb(this.props.newhsv);

    this.props.red = rgb[0];
    this.props.green = rgb[1];
    this.props.blue = rgb[2];
    lightify.node_color(this.mac, this.props.red, this.props.green, this.props.blue, 255);
    this.flush();
  }
github thebespokepixel / trucolor / src / lib / classes / interpreter.js View on Github external
rgb: converter.hex.rgb(this.name)
					}
				case 'RGB':
					return {
						name: converter.rgb.hex(source.input),
						rgb: converter.hex.rgb(this.name)
					}
				case 'HSL':
					return {
						name: converter.hsl.hex(source.input),
						rgb: converter.hsl.rgb(source.input)
					}
				case 'HSV':
					return {
						name: converter.hsv.hex(source.input),
						rgb: converter.hsv.rgb(source.input)
					}
				case 'HWB':
					return {
						name: converter.hwb.hex(source.input),
						rgb: converter.hwb.rgb(source.input)
					}
				case 'SGR':
					return {
						name: source.input,
						rgb: source.input
					}
				case 'named':
					return {
						name: converter.keyword.hex(source.input),
						rgb: converter.keyword.rgb(source.input)
					}
github thebespokepixel / trucolor / src / lib / classes / interpreter.js View on Github external
name: source.input,
						rgb: converter.hex.rgb(this.name)
					}
				case 'RGB':
					return {
						name: converter.rgb.hex(source.input),
						rgb: converter.hex.rgb(this.name)
					}
				case 'HSL':
					return {
						name: converter.hsl.hex(source.input),
						rgb: converter.hsl.rgb(source.input)
					}
				case 'HSV':
					return {
						name: converter.hsv.hex(source.input),
						rgb: converter.hsv.rgb(source.input)
					}
				case 'HWB':
					return {
						name: converter.hwb.hex(source.input),
						rgb: converter.hwb.rgb(source.input)
					}
				case 'SGR':
					return {
						name: source.input,
						rgb: source.input
					}
				case 'named':
					return {
						name: converter.keyword.hex(source.input),
						rgb: converter.keyword.rgb(source.input)
github thebespokepixel / trucolor / lib / index-es.js View on Github external
name: source.input,
						rgb: converter.hex.rgb(this.name)
					}
				case 'RGB':
					return {
						name: converter.rgb.hex(source.input),
						rgb: converter.hex.rgb(this.name)
					}
				case 'HSL':
					return {
						name: converter.hsl.hex(source.input),
						rgb: converter.hsl.rgb(source.input)
					}
				case 'HSV':
					return {
						name: converter.hsv.hex(source.input),
						rgb: converter.hsv.rgb(source.input)
					}
				case 'HWB':
					return {
						name: converter.hwb.hex(source.input),
						rgb: converter.hwb.rgb(source.input)
					}
				case 'SGR':
					return {
						name: source.input,
						rgb: source.input
					}
				case 'named':
					return {
						name: converter.keyword.hex(source.input),
						rgb: converter.keyword.rgb(source.input)