Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Template:RGBtoHSL.L/doc

From Wikipedia, the free encyclopedia

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
{{RGBtoHSL.L|r|g|b}}
The range of the three parameters is [0..255] ; they can be any numeric expressions.
{{subst:RGBtoHSL.L|r|g|b|subst=subst:}}
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
  • "{{RGBtoHSL.L|0|0|0}}" returns "0".
  • "{{RGBtoHSL.L|0|0|1}}" returns "0.002".
  • "{{RGBtoHSL.L|0|1|0}}" returns "0.002".
  • "{{RGBtoHSL.L|0|1|1}}" returns "0.002".
  • "{{RGBtoHSL.L|1|0|0}}" returns "0.002".
  • "{{RGBtoHSL.L|1|0|1}}" returns "0.002".
  • "{{RGBtoHSL.L|1|1|0}}" returns "0.002".
  • "{{RGBtoHSL.L|1|1|1}}" returns "0.004".
  • "{{RGBtoHSL.L|127|127|127}}" returns "0.498".
  • "{{RGBtoHSL.L|127.5|127.5|127.5}}" returns "0.5".
  • "{{RGBtoHSL.L|128|128|128}}" returns "0.502".
  • "{{RGBtoHSL.L|255|255|254}}" returns "0.998".
  • "{{RGBtoHSL.L|255|255|255}}" returns "1".
  • "{{RGBtoHSL.L|255|0|0}}" returns "0.5".
  • "{{RGBtoHSL.L|255|1|0}}" returns "0.5".
  • "{{RGBtoHSL.L|255|127.5|0}}" returns "0.5".
  • "{{RGBtoHSL.L|255|255|0}}" returns "0.5".
  • "{{RGBtoHSL.L|127.5|255|0}}" returns "0.5".
  • "{{RGBtoHSL.L|0|255|0}}" returns "0.5".
  • "{{RGBtoHSL.L|0|255|127.5}}" returns "0.5".
  • "{{RGBtoHSL.L|0|255|255}}" returns "0.5".
  • "{{RGBtoHSL.L|0|127.5|255}}" returns "0.5".
  • "{{RGBtoHSL.L|0|0|255}}" returns "0.5".
  • "{{RGBtoHSL.L|127.5|0|255}}" returns "0.5".
  • "{{RGBtoHSL.L|255|0|255}}" returns "0.5".
  • "{{RGBtoHSL.L|255|0|127.5}}" returns "0.5".
  • "{{RGBtoHSL.L|255|0|1}}" returns "0.5".
  • example for "sandybrown" = "#F4A460" = "rgb(244, 164, 96)" = "hsl(27.6, 0.871, 0.667)"
"{{RGBtoHSL.L|244|164|96}}" returns "0.667".
  • same example using subst
"{{subst:RGBtoHSL.L|244|164|96|subst=subst:}}" returns "0.667".


See also