<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://themidnight.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AColor_contrast</id>
	<title>Module:Color contrast - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://themidnight.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AColor_contrast"/>
	<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;action=history"/>
	<updated>2026-04-03T23:02:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=17031&amp;oldid=prev</id>
		<title>Timothy: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=17031&amp;oldid=prev"/>
		<updated>2025-08-05T14:21:30Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:21, 5 August 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Timothy</name></author>
	</entry>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=17030&amp;oldid=prev</id>
		<title>wikipedia&gt;Pppery: Tweak default color per request</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=17030&amp;oldid=prev"/>
		<updated>2025-03-30T20:30:40Z</updated>

		<summary type="html">&lt;p&gt;Tweak default color per request&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:30, 30 March 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l133&quot;&gt;Line 133:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 133:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local css = (args[&amp;#039;css&amp;#039;] and args[&amp;#039;css&amp;#039;] ~= &amp;#039;&amp;#039;) and true or false&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local css = (args[&amp;#039;css&amp;#039;] and args[&amp;#039;css&amp;#039;] ~= &amp;#039;&amp;#039;) and true or false&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local v1 = color2lum(args[1] or &amp;#039;&amp;#039;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local v1 = color2lum(args[1] or &amp;#039;&amp;#039;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local c2 = args[2] or &#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;#FFFFFF&lt;/del&gt;&#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local c2 = args[2] or &#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;white&lt;/ins&gt;&#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local v2 = color2lum(c2)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local v2 = color2lum(c2)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local c3 = args[3] or &#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;#000000&lt;/del&gt;&#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local c3 = args[3] or &#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;black&lt;/ins&gt;&#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local v3 = color2lum(c3)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local v3 = color2lum(c3)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local ratio1 = -1;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local ratio1 = -1;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>wikipedia&gt;Pppery</name></author>
	</entry>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=2096&amp;oldid=prev</id>
		<title>Timothy: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=2096&amp;oldid=prev"/>
		<updated>2022-03-24T16:57:31Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:57, 24 March 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Timothy</name></author>
	</entry>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=2095&amp;oldid=prev</id>
		<title>wikipedia&gt;Johnuniq: fix unintended color2lum global error which is causing errors; clean whitespace</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:Color_contrast&amp;diff=2095&amp;oldid=prev"/>
		<updated>2019-01-06T22:38:25Z</updated>

		<summary type="html">&lt;p&gt;fix unintended color2lum global error which is causing errors; clean whitespace&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&lt;br /&gt;
-- This module implements&lt;br /&gt;
--  {{Color contrast ratio}}&lt;br /&gt;
--  {{Greater color contrast ratio}}&lt;br /&gt;
--  {{ColorToLum}}&lt;br /&gt;
--  {{RGBColorToLum}}&lt;br /&gt;
--&lt;br /&gt;
local p = {}&lt;br /&gt;
local HTMLcolor = mw.loadData( &amp;#039;Module:Color contrast/colors&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
local function sRGB (v)&lt;br /&gt;
	if (v &amp;lt;= 0.03928) then&lt;br /&gt;
		v = v / 12.92&lt;br /&gt;
	else&lt;br /&gt;
		v = math.pow((v+0.055)/1.055, 2.4)&lt;br /&gt;
	end&lt;br /&gt;
	return v&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function rgbdec2lum(R, G, B)&lt;br /&gt;
	if ( 0 &amp;lt;= R and R &amp;lt; 256 and 0 &amp;lt;= G and G &amp;lt; 256 and 0 &amp;lt;= B and B &amp;lt; 256 ) then&lt;br /&gt;
		return 0.2126 * sRGB(R/255) + 0.7152 * sRGB(G/255) + 0.0722 * sRGB(B/255)&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function hsl2lum(h, s, l)&lt;br /&gt;
	if ( 0 &amp;lt;= h and h &amp;lt; 360 and 0 &amp;lt;= s and s &amp;lt;= 1 and 0 &amp;lt;= l and l &amp;lt;= 1 ) then&lt;br /&gt;
		local c = (1 - math.abs(2*l - 1))*s&lt;br /&gt;
		local x = c*(1 - math.abs( math.fmod(h/60, 2) - 1) )&lt;br /&gt;
		local m = l - c/2&lt;br /&gt;
&lt;br /&gt;
		local r, g, b = m, m, m&lt;br /&gt;
		if( 0 &amp;lt;= h and h &amp;lt; 60 ) then&lt;br /&gt;
			r = r + c&lt;br /&gt;
			g = g + x&lt;br /&gt;
		elseif( 60 &amp;lt;= h and h &amp;lt; 120 ) then&lt;br /&gt;
			r = r + x&lt;br /&gt;
			g = g + c&lt;br /&gt;
		elseif( 120 &amp;lt;= h and h &amp;lt; 180 ) then&lt;br /&gt;
			g = g + c&lt;br /&gt;
			b = b + x&lt;br /&gt;
		elseif( 180 &amp;lt;= h and h &amp;lt; 240 ) then&lt;br /&gt;
			g = g + x&lt;br /&gt;
			b = b + c&lt;br /&gt;
		elseif( 240 &amp;lt;= h and h &amp;lt; 300 ) then&lt;br /&gt;
			r = r + x&lt;br /&gt;
			b = b + c&lt;br /&gt;
		elseif( 300 &amp;lt;= h and h &amp;lt; 360 ) then&lt;br /&gt;
			r = r + c&lt;br /&gt;
			b = b + x&lt;br /&gt;
		end&lt;br /&gt;
		return rgbdec2lum(255*r, 255*g, 255*b)&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function color2lum(c)&lt;br /&gt;
&lt;br /&gt;
	if (c == nil) then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- html &amp;#039;#&amp;#039; entity&lt;br /&gt;
	c = c:gsub(&amp;quot;&amp;amp;#35;&amp;quot;, &amp;quot;#&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- whitespace&lt;br /&gt;
	c = c:match( &amp;#039;^%s*(.-)[%s;]*$&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
	-- unstrip nowiki strip markers&lt;br /&gt;
	c = mw.text.unstripNoWiki(c)&lt;br /&gt;
&lt;br /&gt;
	-- lowercase&lt;br /&gt;
	c = c:lower()&lt;br /&gt;
&lt;br /&gt;
	-- first try to look it up&lt;br /&gt;
	local L = HTMLcolor[c]&lt;br /&gt;
	if (L ~= nil) then&lt;br /&gt;
		return L&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- convert from hsl&lt;br /&gt;
	if mw.ustring.match(c,&amp;#039;^hsl%([%s]*[0-9][0-9%.]*[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$&amp;#039;) then&lt;br /&gt;
		local h, s, l = mw.ustring.match(c,&amp;#039;^hsl%([%s]*([0-9][0-9%.]*)[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$&amp;#039;)&lt;br /&gt;
		return hsl2lum(tonumber(h), tonumber(s)/100, tonumber(l)/100)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- convert from rgb&lt;br /&gt;
	if mw.ustring.match(c,&amp;#039;^rgb%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*%)$&amp;#039;) then&lt;br /&gt;
		local R, G, B = mw.ustring.match(c,&amp;#039;^rgb%([%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*%)$&amp;#039;)&lt;br /&gt;
		return rgbdec2lum(tonumber(R), tonumber(G), tonumber(B))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- convert from rgb percent&lt;br /&gt;
	if mw.ustring.match(c,&amp;#039;^rgb%([%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$&amp;#039;) then&lt;br /&gt;
		local R, G, B = mw.ustring.match(c,&amp;#039;^rgb%([%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$&amp;#039;)&lt;br /&gt;
		return rgbdec2lum(255*tonumber(R)/100, 255*tonumber(G)/100, 255*tonumber(B)/100)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- remove leading # (if there is one) and whitespace&lt;br /&gt;
	c = mw.ustring.match(c, &amp;#039;^[%s#]*([a-f0-9]*)[%s]*$&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	-- split into rgb&lt;br /&gt;
	local cs = mw.text.split(c or &amp;#039;&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	if( #cs == 6 ) then&lt;br /&gt;
		local R = 16*tonumber(&amp;#039;0x&amp;#039; .. cs[1]) + tonumber(&amp;#039;0x&amp;#039; .. cs[2])&lt;br /&gt;
		local G = 16*tonumber(&amp;#039;0x&amp;#039; .. cs[3]) + tonumber(&amp;#039;0x&amp;#039; .. cs[4])&lt;br /&gt;
		local B = 16*tonumber(&amp;#039;0x&amp;#039; .. cs[5]) + tonumber(&amp;#039;0x&amp;#039; .. cs[6])&lt;br /&gt;
&lt;br /&gt;
		return rgbdec2lum(R, G, B)&lt;br /&gt;
	elseif ( #cs == 3 ) then&lt;br /&gt;
		local R = 16*tonumber(&amp;#039;0x&amp;#039; .. cs[1]) + tonumber(&amp;#039;0x&amp;#039; .. cs[1])&lt;br /&gt;
		local G = 16*tonumber(&amp;#039;0x&amp;#039; .. cs[2]) + tonumber(&amp;#039;0x&amp;#039; .. cs[2])&lt;br /&gt;
		local B = 16*tonumber(&amp;#039;0x&amp;#039; .. cs[3]) + tonumber(&amp;#039;0x&amp;#039; .. cs[3])&lt;br /&gt;
&lt;br /&gt;
		return rgbdec2lum(R, G, B)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- failure, return blank&lt;br /&gt;
	return &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This exports the function for use in other modules.&lt;br /&gt;
-- The colour is passed as a string.&lt;br /&gt;
function p._lum(color)&lt;br /&gt;
	return color2lum(color)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._greatercontrast(args)&lt;br /&gt;
	local bias = tonumber(args[&amp;#039;bias&amp;#039;] or &amp;#039;0&amp;#039;) or 0&lt;br /&gt;
	local css = (args[&amp;#039;css&amp;#039;] and args[&amp;#039;css&amp;#039;] ~= &amp;#039;&amp;#039;) and true or false&lt;br /&gt;
	local v1 = color2lum(args[1] or &amp;#039;&amp;#039;)&lt;br /&gt;
	local c2 = args[2] or &amp;#039;#FFFFFF&amp;#039;&lt;br /&gt;
	local v2 = color2lum(c2)&lt;br /&gt;
	local c3 = args[3] or &amp;#039;#000000&amp;#039;&lt;br /&gt;
	local v3 = color2lum(c3)&lt;br /&gt;
	local ratio1 = -1;&lt;br /&gt;
	local ratio2 = -1;&lt;br /&gt;
	if (type(v1) == &amp;#039;number&amp;#039; and type(v2) == &amp;#039;number&amp;#039;) then&lt;br /&gt;
		ratio1 = (v2 + 0.05)/(v1 + 0.05)&lt;br /&gt;
		ratio1 = (ratio1 &amp;lt; 1) and 1/ratio1 or ratio1&lt;br /&gt;
	end&lt;br /&gt;
	if (type(v1) == &amp;#039;number&amp;#039; and type(v3) == &amp;#039;number&amp;#039;) then&lt;br /&gt;
		ratio2 = (v3 + 0.05)/(v1 + 0.05)&lt;br /&gt;
		ratio2 = (ratio2 &amp;lt; 1) and 1/ratio2 or ratio2&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if css then&lt;br /&gt;
		local c1 = args[1] or &amp;#039;&amp;#039;&lt;br /&gt;
		if mw.ustring.match(c1, &amp;#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&amp;#039;) or&lt;br /&gt;
			mw.ustring.match(c1, &amp;#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&amp;#039;) then&lt;br /&gt;
				c1 = &amp;#039;#&amp;#039; .. c1&lt;br /&gt;
		end&lt;br /&gt;
		if mw.ustring.match(c2, &amp;#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&amp;#039;) or&lt;br /&gt;
			mw.ustring.match(c2, &amp;#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&amp;#039;) then&lt;br /&gt;
				c2 = &amp;#039;#&amp;#039; .. c2&lt;br /&gt;
		end&lt;br /&gt;
		if mw.ustring.match(v3, &amp;#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&amp;#039;) or&lt;br /&gt;
			mw.ustring.match(v3, &amp;#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&amp;#039;) then&lt;br /&gt;
				c3 = &amp;#039;#&amp;#039; .. c3&lt;br /&gt;
		end&lt;br /&gt;
		return &amp;#039;background-color:&amp;#039; .. c1 .. &amp;#039;; color:&amp;#039; .. ((ratio1 &amp;gt; 0) and (ratio2 &amp;gt; 0) and ((ratio1 + bias &amp;gt; ratio2) and c2 or c3) or &amp;#039;&amp;#039;) .. &amp;#039;;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return (ratio1 &amp;gt; 0) and (ratio2 &amp;gt; 0) and ((ratio1 + bias &amp;gt; ratio2) and c2 or c3) or &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._ratio(args)&lt;br /&gt;
	local v1 = color2lum(args[1])&lt;br /&gt;
	local v2 = color2lum(args[2])&lt;br /&gt;
	if (type(v1) == &amp;#039;number&amp;#039; and type(v2) == &amp;#039;number&amp;#039;) then&lt;br /&gt;
		-- v1 should be the brighter of the two.&lt;br /&gt;
		if v2 &amp;gt; v1 then&lt;br /&gt;
			v1, v2 = v2, v1&lt;br /&gt;
		end&lt;br /&gt;
		return (v1 + 0.05)/(v2 + 0.05)&lt;br /&gt;
	else&lt;br /&gt;
		return args[&amp;#039;error&amp;#039;] or &amp;#039;?&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._styleratio(args)&lt;br /&gt;
	local style = (args[1] or &amp;#039;&amp;#039;):lower()&lt;br /&gt;
	local bg, fg = &amp;#039;white&amp;#039;, &amp;#039;black&amp;#039;&lt;br /&gt;
	local lum_bg, lum_fg = 1, 0&lt;br /&gt;
&lt;br /&gt;
	if args[2] then&lt;br /&gt;
		local lum = color2lum(args[2])&lt;br /&gt;
		if lum ~= &amp;#039;&amp;#039; then bg, lum_bg = args[2], lum end&lt;br /&gt;
	end&lt;br /&gt;
	if args[3] then&lt;br /&gt;
		local lum = color2lum(args[3])&lt;br /&gt;
		if lum ~= &amp;#039;&amp;#039; then fg, lum_fg = args[3], lum end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local slist = mw.text.split(mw.ustring.gsub(mw.ustring.gsub(style or &amp;#039;&amp;#039;, &amp;#039;&amp;amp;#[Xx]23;&amp;#039;, &amp;#039;#&amp;#039;), &amp;#039;&amp;amp;#35;&amp;#039;, &amp;#039;#&amp;#039;), &amp;#039;;&amp;#039;)&lt;br /&gt;
	for k = 1,#slist do&lt;br /&gt;
		local s = slist[k]&lt;br /&gt;
		local k,v = s:match( &amp;#039;^[%s]*([^:]-):([^:]-)[%s;]*$&amp;#039; )&lt;br /&gt;
		k = k or &amp;#039;&amp;#039;&lt;br /&gt;
		v = v or &amp;#039;&amp;#039;&lt;br /&gt;
		if (k:match(&amp;#039;^[%s]*(background)[%s]*$&amp;#039;) or k:match(&amp;#039;^[%s]*(background%-color)[%s]*$&amp;#039;)) then&lt;br /&gt;
			local lum = color2lum(v)&lt;br /&gt;
			if( lum ~= &amp;#039;&amp;#039; ) then bg, lum_bg = v, lum end&lt;br /&gt;
		elseif (k:match(&amp;#039;^[%s]*(color)[%s]*$&amp;#039;)) then&lt;br /&gt;
			local lum = color2lum(v)&lt;br /&gt;
			if( lum ~= &amp;#039;&amp;#039; ) then bg, lum_fg = v, lum end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if lum_bg &amp;gt; lum_fg then&lt;br /&gt;
		return (lum_bg + 0.05)/(lum_fg + 0.05)&lt;br /&gt;
	else&lt;br /&gt;
		return (lum_fg + 0.05)/(lum_bg + 0.05)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Use {{#invoke:Color contrast|somecolor}} directly or&lt;br /&gt;
{{#invoke:Color contrast}} from a wrapper template.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
	-- |1=	— required; A color to check.&lt;br /&gt;
--]]&lt;br /&gt;
function p.lum(frame)&lt;br /&gt;
	local color = frame.args[1] or frame:getParent().args[1]&lt;br /&gt;
	return p._lum(color)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.ratio(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	return p._ratio(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.styleratio(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	return p._styleratio(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.greatercontrast(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	return p._greatercontrast(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Johnuniq</name></author>
	</entry>
</feed>