Set the color with HSL (hue, saturation, lightness) values

@param hue
hue value inclusively between 0.0 and 360.0
@param saturation
saturation inclusively between 0.0 and 1.0
@param lightness
lightness inclusively between 0.0 and 1.0
168826
public void setColorByHSL(float hue, float saturation, float lightness) {
		float[] arithmeticRGB = ColorUtils.toArithmeticRGB(hue, saturation,
				lightness);
		setRed(arithmeticRGB[0]);
		setGreen(arithmeticRGB[1]);
		setBlue(arithmeticRGB[2]);
	}
1330851
def set_hsb(self, hue, saturation, brightness=None, *, index=0,
                transition_time=None):
        """"""
        self._value_validate(hue, RANGE_HUE, "Hue")
        self._value_validate(saturation, RANGE_SATURATION, "Saturation")

        values = {
            ATTR_LIGHT_COLOR_SATURATION: saturation,
            ATTR_LIGHT_COLOR_HUE: hue
        }

        if brightness is not None:
            values[ATTR_LIGHT_DIMMER] = brightness
            self._value_validate(brightness, RANGE_BRIGHTNESS, "Brightness")

        if transition_time is not None:
            values[ATTR_TRANSITION_TIME] = transition_time

        return self.set_values(values, index=index)
726101
def color(ip, mac, hue, saturation, value):
    """"""
    bulb = MyStromBulb(ip, mac)
    bulb.set_color_hsv(hue, saturation, value)
505777
public void setCenterColor(Color color) {
        if (centerColor == null) {
            centerColor = new RGBColor(0.0, 0.0, 0.0);
        }
        setGradation(true);
        this.centerColor = color;
    }
400459
def color(self, color):
        
        self._color = color
        self.saturation = saturation_of_color(color)
        if self.saturation != 0:
            self.hue = hue_of_color(color)
57300
def set_color_hsv(self, hue, saturation, value):
        """"""
        try:
            data = "action=on&color={};{};{}".format(hue, saturation, value)
            request = requests.post(
                '{}/{}/{}'.format(self.resource, URI, self._mac),
                data=data, timeout=self.timeout)
            if request.status_code == 200:
                self.data['on'] = True
        except requests.exceptions.ConnectionError:
            raise exceptions.MyStromConnectionError()
109165
function hslToRgb(h, s, l) {

  h /= 360;
  s /= 100;
  l /= 100;

  var r, g, b;

  if (s === 0) {
    r = g = b = l; // achromatic
  } else {
    var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
    var p = 2 * l - q;
    r = hueToRgb(p, q, h + 1 / 3);
    g = hueToRgb(p, q, h);
    b = hueToRgb(p, q, h - 1 / 3);
  }

  return ({
    r: r * 255,
    g: g * 255,
    b: b * 255
  });
}
994117
public void setColor(int color, boolean callback) {

    int alpha = Color.alpha(color);
    int red = Color.red(color);
    int blue = Color.blue(color);
    int green = Color.green(color);

    float[] hsv = new float[3];

    Color.RGBToHSV(red, green, blue, hsv);

    this.alpha = alpha;
    hue = hsv[0];
    sat = hsv[1];
    val = hsv[2];

    if (callback && onColorChangedListener != null) {
      onColorChangedListener.onColorChanged(Color.HSVToColor(this.alpha, new float[] { hue, sat, val }));
    }

    invalidate();
  }
994959
public static void setPreferredColor(int color) {
		final Preferences prefs = Preferences.userNodeForPackage(MapElementConstants.class);
		if (prefs != null) {
			prefs.putInt("COLOR", color); //$NON-NLS-1$
			try {
				prefs.flush();
			} catch (BackingStoreException exception) {
				//
			}
		}
	}
413062
public static final Color fromNormalizedHSL(final double h, final double s, final double l)
    {
        // see http://www.w3.org/TR/css3-color/
        //
        // HOW TO RETURN hsl.to.rgb(h, s, l):
        // SELECT:
        // l<=0.5: PUT l*(s+1) IN m2
        // ELSE: PUT l+s-l*s IN m2
        // PUT l*2-m2 IN m1
        // PUT hue.to.rgb(m1, m2, h+1/3) IN r
        // PUT hue.to.rgb(m1, m2, h ) IN g
        // PUT hue.to.rgb(m1, m2, h-1/3) IN b
        // RETURN (r, g, b)

        final double m2 = (l <= 0.5) ? (l * (s + 1)) : ((l + s) - (l * s));

        final double m1 = (l * 2) - m2;

        return new Color(fixRGB((int) Math.round(255 * hueToRGB(m1, m2, h + (1.0 / 3)))), fixRGB((int) Math.round(255 * hueToRGB(m1, m2, h))), fixRGB((int) Math.round(255 * hueToRGB(m1, m2, h - (1.0 / 3)))));
    }
710247
public function modulate($brightness = null, $saturation = null, $hue = null) {
        $params = array();

        if ($brightness) {
            $params[] = 'b=' . (int) $brightness;
        }

        if ($saturation) {
            $params[] = 's=' . (int) $saturation;
        }

        if ($hue) {
            $params[] = 'h=' . (int) $hue;
        }

        if (!$params) {
            throw new InvalidArgumentException('brightness, saturation and/or hue must be specified');
        }

        return $this->addTransformation(sprintf('modulate:%s', implode(',', $params)));
    }
160426
function( hsl ){
      var ret;
      var number = $$.util.regex.number;
      var h, s, l, a, r, g, b;
      function hue2rgb(p, q, t){
        if(t < 0) t += 1;
        if(t > 1) t -= 1;
        if(t < 1/6) return p + (q - p) * 6 * t;
        if(t < 1/2) return q;
        if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
        return p;
      }

      var m = new RegExp("^" + $$.util.regex.hsla + "$").exec(hsl);
      if( m ){

        // get hue
        h = parseInt( m[1] ); 
        if( h < 0 ){
          h = ( 360 - (-1*h % 360) ) % 360;
        } else if( h > 360 ){
          h = h % 360;
        }
        h /= 360; // normalise on [0, 1]

        s = parseFloat( m[2] );
        if( s < 0 || s > 100 ){ return; } // saturation is [0, 100]
        s = s/100; // normalise on [0, 1]

        l = parseFloat( m[3] );
        if( l < 0 || l > 100 ){ return; } // lightness is [0, 100]
        l = l/100; // normalise on [0, 1]

        a = m[4];
        if( a !== undefined ){
          a = parseFloat( a );

          if( a < 0 || a > 1 ){ return; } // alpha is [0, 1]
        }

        // now, convert to rgb
        // code from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
        if( s === 0 ){
          r = g = b = Math.round(l * 255); // achromatic
        } else {
          var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
          var p = 2 * l - q;
          r = Math.round( 255 * hue2rgb(p, q, h + 1/3) );
          g = Math.round( 255 * hue2rgb(p, q, h) );
          b = Math.round( 255 * hue2rgb(p, q, h - 1/3) );
        }

        ret = [r, g, b, a];
      }

      return ret;
    }
1258124
def weight_color_hsl(weight, weight_range, min_lightness=0.8):
    # type: (float, float, float) -> _HSL_COLOR
    
    hue = _hue(weight)
    saturation = 1
    rel_weight = (abs(weight) / weight_range) ** 0.7
    lightness = 1.0 - (1 - min_lightness) * rel_weight
    return hue, saturation, lightness
1286174
def set_hue(self, hue, duration=0, rapid=False):
        
        color = self.get_color()
        color2 = (hue, color[1], color[2], color[3])
        try:
            if rapid:
                self.fire_and_forget(LightSetColor, {"color": color2, "duration": duration}, num_repeats=1)
            else:
                self.req_with_ack(LightSetColor, {"color": color2, "duration": duration})
        except WorkflowException as e:
            raise
803087
public void setHSV(int hue, int sat, int bri) throws Exception {

        CmsColor color = new CmsColor();
        color.setHSV(hue, sat, bri);

        m_red = color.getRed();
        m_green = color.getGreen();
        m_blue = color.getBlue();
        m_hue = hue;
        m_saturation = sat;
        m_brightness = bri;

        m_tbRed.setText(Integer.toString(m_red));
        m_tbGreen.setText(Integer.toString(m_green));
        m_tbBlue.setText(Integer.toString(m_blue));
        m_tbHue.setText(Integer.toString(m_hue));
        m_tbSaturation.setText(Integer.toString(m_saturation));
        m_tbBrightness.setText(Integer.toString(m_brightness));
        m_tbHexColor.setText(color.getHex());
        setPreview(color.getHex());

        updateSliders();
    }
1357205
private static float hslConvert(float t1, float t2, float hue) {
		float value;
		if (hue < 0) {
			hue += 6;
		}
		if (hue >= 6) {
			hue -= 6;
		}
		if (hue < 1) {
			value = (t2 - t1) * hue + t1;
		} else if (hue < 3) {
			value = t2;
		} else if (hue < 4) {
			value = (t2 - t1) * (4 - hue) + t1;
		} else {
			value = t1;
		}
		return value;
	}
658628
public static Color rotateHue (Color color, float fraction) {

		float[] af = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);

		float hue = af[0];
		float saturation = af[1];
		float brightness = af[2];

		float hueNew = hue  + fraction;

		Color hsb = Color.getHSBColor(hueNew, saturation, brightness);
		return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), color.getAlpha());
	}