Template:RGBtoHSL.L/doc

This template computes the lightness value in [0..1] 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 three decimals (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 replace the template invokation by the computed value when saving an article Wiki source.


 * Algorithm used
 * L = (max(r, g, b) + min(r, g, b)) / 255 / 2;
 * return L round 3;


 * Examples
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " returns "".
 * " " 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 "0.667".


 * See also
 * Template:RGBtoHSL.H, Template:RGBtoHSL.S
 * Template:HSLtoRGB.R, Template:HSLtoRGB.G, Template:HSLtoRGB.B