这是Module:Color contrast的文档页面
此模块文档依赖以下Lua模块:
此模块主要用于以下模版:
- {{Color contrast ratio}}
- {{ColorToLum}} / {{RGBColorToLum}}
- {{Color contrast conformance}}
- {{Ensure AAA contrast ratio}}
- {{Ensure AA contrast ratio}}
- {{Greater color contrast ratio}}
此模版也用于以下模块:
并且用于以下模块的说明文档页面:
函数说明
sRGB(v)
:从sRGB色彩空间的非线性转换:此函数所用到的常数则是使用<math>\left(\frac{K_0+a}{1+a}\right)^\gamma=\frac{K_0}{\phi}</math>与<math>\gamma\left(\frac{K_0+a}{1+a}\right)^{\gamma-1}\left(\frac{1}{1+a}\right)=\frac{1}{\phi}</math>这2个方程式代入<math>a=0.055</math>、<math>\gamma=2.4</math>得到<math>\phi=12.92</math>与<math>K_0=0.03928</math>rgbdec2lum(R,G,B)
:从三原色光模式转成CIE XYZ的Y值hsl2lum(h,s,l)
:从HSL色彩空间转成CIE XYZ的Y值,其中h
所用的单位为度color2lum(c)
:从HTML颜色转成CIE XYZ的Y值
用法
To use this module, you may use one of the above listed templates or invoke the module directly
To compute relative luminescence
{{ColorToLum|color}}
or{{#invoke:Color contrast|lum|color}}
To compute a contrast ratio between two colors
{{Color contrast ratio|color1|color2|error=?}}
or{{#invoke:Color contrast|ratio|color1|color2|error=?}}
To determine which of two colors (color2a and color2b) has the greater contrast ratio with a particular color (color1)
{{Greater color contrast ratio|color1|color2a|color2b}}
or{{#invoke:Color contrast|greatercontrast|color1|color2a|color2b}}
To compute the contrast ratio between the background and text colors specified in a css style string
{{#invoke:Color contrast|styleratio|css style statement string|default background color|default text color}}