# 模組:Color contrast/doc

{{Color contrast ratio}}
{{ColorToLum}} / {{RGBColorToLum}}
{{Color contrast conformance}}
{{Ensure AAA contrast ratio}}
{{Ensure AA contrast ratio}}
{{Greater color contrast ratio}}

Module:Navbox
Module:Userbox
Module:Episode list

Module:College color

## 函數說明

• sRGB(v)：從sRGB色彩空間的非線性轉換：此函數所用到的常數則是使用${\displaystyle \left({\frac {K_{0}+a}{1+a}}\right)^{\gamma }={\frac {K_{0}}{\phi }}}$${\displaystyle \gamma \left({\frac {K_{0}+a}{1+a}}\right)^{\gamma -1}\left({\frac {1}{1+a}}\right)={\frac {1}{\phi }}}$這2個方程式代入${\displaystyle a=0.055}$${\displaystyle \gamma =2.4}$得到${\displaystyle \phi =12.92}$${\displaystyle K_{0}=0.03928}$
• 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}}