How to use the color.hsv function in color

To help you get started, we’ve selected a few color 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 Bastl34 / node-yeelight-wifi / yeelight.js View on Github external
updateHSV(hue,sat,val)
    {
        if (typeof val !== 'undefined' && val != "")
            this.bright = parseInt(val);

        this.hsb.h = parseInt(hue);
        this.hsb.s = parseInt(sat);
        this.hsb.b = this.bright;

        let rgb = Color.hsv([this.hsb.h,this.hsb.s,this.hsb.b]).rgb();

        this.rgb.r = rgb.color[0];
        this.rgb.g = rgb.color[1];
        this.rgb.b = rgb.color[2];

        //console.log("updateByRGB => new rgb: ",this.rgb);
        this.emit('stateUpdate',this);
    }
github Bastl34 / node-yeelight-wifi / yeelight.js View on Github external
setHSV(hsv,duration)
    {
        let color = Color.hsv(hsv);

        let hue = color.hue();
        let sat = color.saturationv();
        let bright = color.value();

        //update local state
        this.updateHSV(hue,sat,bright);

        //"hue", "sat", "effect", "duration"
        let params =
        [
            hue,
            sat,
            (duration) ? "smooth" : "sudden",
            (duration) ? duration : 0
        ];