Module:Color contrast/doc
This is the documentation page for Module:Color contrast
Computes the relative luminance of CSS colors and the contrast ratio between two colors (the WCAG formula). It is an older copy of Wikipedia's Module:Color contrast.
On this wiki only Module:Navbox uses it: on template pages, _styleratio checks every *style parameter of a navbox, and a ratio below 4.5 adds the tracking category "Potentially illegible navboxes". The wrapper templates named at the top of the source ({{Color contrast ratio}} and others) don't exist here.
Colors can be CSS names (looked up in Module:Color contrast/colors), #rgb, #rrggbb, rgb() with numbers or percentages, and hsl(). A color it can't read gives an empty string.
Entry points for #invoke take positional arguments from the invoke, or from the calling template when the invoke has none:
lum: the luminance of color1, from 0 (black) to 1 (white).ratio: the contrast ratio of colors1and2.errorsets the text for colors it can't read (default?).styleratio: the contrast betweenbackgroundorbackground-colorandcolorin the CSS text1.2and3are the background and text colors to assume when the CSS doesn't set them (white and black).greatercontrast: of colors2(default white) and3(default black), the one with more contrast against color1.biasfavors color2;cssreturns abackground-color: …; color: …;declaration instead.
Lua modules call the same functions with an underscore: _lum(color), _ratio(args), _styleratio(args) and _greatercontrast(args).