Difference between revisions of "Template:ColorToLum/doc"

From blackwiki
Jump to navigation Jump to search
imported>Frietjes
imported>DePiep
({{sandbox other}} regular)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
 +
{{High-use|12455}}
 
{{Lua|Module:Color contrast}}
 
{{Lua|Module:Color contrast}}
 +
 
Converts most legal [[web colors]] to a [http://www.w3.org/TR/2012/NOTE-WCAG20-TECHS-20120103/G18 W3C relative luminance value].  The color may be specified as either by [[Web colors#HTML color names|HTML color name]] or by [[Web_colors#CSS_colors|HSL]] or by [[Web_colors#CSS_colors|RGB]] or by [[Web_colors#CSS_colors|Hex value]].
 
Converts most legal [[web colors]] to a [http://www.w3.org/TR/2012/NOTE-WCAG20-TECHS-20120103/G18 W3C relative luminance value].  The color may be specified as either by [[Web colors#HTML color names|HTML color name]] or by [[Web_colors#CSS_colors|HSL]] or by [[Web_colors#CSS_colors|RGB]] or by [[Web_colors#CSS_colors|Hex value]].
  
Line 50: Line 52:
 
|}
 
|}
  
<includeonly>{{basepage subpage|
+
<includeonly>{{sandbox other||
 
<!-- Categories below this line, please; interwikis at Wikidata -->
 
<!-- Categories below this line, please; interwikis at Wikidata -->
 
[[Category:Color conversion templates]]
 
[[Category:Color conversion templates]]
 
}}</includeonly>
 
}}</includeonly>

Latest revision as of 20:07, 24 April 2020

Converts most legal web colors to a W3C relative luminance value. The color may be specified as either by HTML color name or by HSL or by RGB or by Hex value.

Examples

  • {{ColorToLum|Lime}} → 0.7152
  • {{ColorToLum|hsl(120,100%,50%)}} → 0.7152
  • {{ColorToLum|#00FF00}} → 0.7152
  • {{ColorToLum|rgb(0,255,0)}} → 0.7152
  • {{ColorToLum|rgb(0.0%,100.0%,0.0%)}} → 0.7152

Consistency check

Color Computed Relative Luminance
From Name From HSL From Hex From RGB From RGB%
Black 0 0 0 0 0
White 1 1 1 1 1
Red 0.2126 0.2126 0.2126 0.2126 0.2126
Lime 0.7152 0.7152 0.7152 0.7152 0.7152
Blue 0.0722 0.0722 0.0722 0.0722 0.0722
Yellow 0.9278 0.9278 0.9278 0.9278 0.9278
Cyan 0.7874 0.7874 0.7874 0.7874 0.7874
Magenta 0.2848 0.2848 0.2848 0.2848 0.2848
Silver 0.52711512570581 0.52720723642853 0.52711512570581 0.52711512570581 0.52720723642853
Gray 0.2158605001139 0.21589697895456 0.2158605001139 0.2158605001139 0.21589697895456
Maroon 0.045891942324215 0.045899697725739 0.045891942324215 0.045891942324215 0.045899697725739
Olive 0.20027537200568 0.20030921707404 0.20027537200568 0.20027537200568 0.20030921707404
Green 0.15438342968146 0.1544095193483 0.15438342968146 0.15438342968146 0.1544095193483
Purple 0.061477070432439 0.061487459606258 0.061477070432439 0.061477070432439 0.061487459606258
Teal 0.16996855778968 0.16999728122882 0.16996855778968 0.16996855778968 0.16999728122882
Navy 0.015585128108224 0.015587761880519 0.015585128108224 0.015585128108224 0.015587761880519