Template:RGBtoHSL.H/doc

This template computes the hue value in degrees [0..360) in the HSL color space (as defined in standard CSS3), from a color specified in the sRGB color space. The returned value is rounded to one decimal (which preserves the precision of RGB colors whose components are specified in the standard range [0..255].


 * Syntax
 * r g b
 * The range of the three parameters is [0..255] ; they can be any numeric expressions.
 * r g b
 * To remplace the template invokation by the computed value when saving an article Wiki source.


 * Algorithm used
 * if r = g and g = b then
 * H = 0;
 * else if g &gt;= r and g &gt;= b then
 * if r &gt; b
 * then H = 120 - 60 * (r - b) / (g - b);
 * else H = 120 + 60 * (b - r) / (g - r);
 * else if b &gt;= r and b &gt;= g then
 * if g &gt; r
 * then H = 240 - 60 * (g - r) / (b - r);
 * else H = 240 + 60 * (r - g) / (b - g);
 * else
 * if b &gt; g
 * then H = 360 - 60 * (b - g) / (r - g);
 * else H =      60 * (g - b) / (r - b);
 * return H round 1;


 * Examples
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * example for "sandybrown" = "#F4A460" = "rgb(244, 164, 96)" = "hsl(27.6, 0.871, 0.667)"
 * " " returns "".


 * same example using subst
 * " " returns "27.6".