<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fa">
	<id>https://wiki.ahlolbait.com/index.php?action=history&amp;feed=atom&amp;title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86%3AColor_contrast</id>
	<title>پودمان:Color contrast - تاریخچهٔ ویرایش‌ها</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ahlolbait.com/index.php?action=history&amp;feed=atom&amp;title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86%3AColor_contrast"/>
	<link rel="alternate" type="text/html" href="https://wiki.ahlolbait.com/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Color_contrast&amp;action=history"/>
	<updated>2026-04-19T21:52:40Z</updated>
	<subtitle>تاریخچهٔ ویرایش‌های این صفحه در ویکی</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.ahlolbait.com/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Color_contrast&amp;diff=105009&amp;oldid=prev</id>
		<title>Zamani: «پودمان:Color contrast» را محافظت کرد ([ویرایش=تنها مدیران] (بی‌پایان) [انتقال=تنها مدیران] (بی‌پایان))</title>
		<link rel="alternate" type="text/html" href="https://wiki.ahlolbait.com/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Color_contrast&amp;diff=105009&amp;oldid=prev"/>
		<updated>2019-05-30T06:11:01Z</updated>

		<summary type="html">&lt;p&gt;«&lt;a href=&quot;/%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Color_contrast&quot; title=&quot;پودمان:Color contrast&quot;&gt;پودمان:Color contrast&lt;/a&gt;» را محافظت کرد ([ویرایش=تنها مدیران] (بی‌پایان) [انتقال=تنها مدیران] (بی‌پایان))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;fa&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;→ نسخهٔ قدیمی‌تر&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;نسخهٔ ‏۳۰ مهٔ ۲۰۱۹، ساعت ۰۶:۱۱&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;fa&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(بدون تفاوت)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Zamani</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.ahlolbait.com/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Color_contrast&amp;diff=104685&amp;oldid=prev</id>
		<title>Zamani: صفحه‌ای تازه حاوی «-- -- This module implements  --  {{Color contrast ratio}} --  {{Greater color contrast ratio}} --  {{ColorToLum}} --  {{RGBColorToLum}} --...» ایجاد کرد</title>
		<link rel="alternate" type="text/html" href="https://wiki.ahlolbait.com/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Color_contrast&amp;diff=104685&amp;oldid=prev"/>
		<updated>2019-05-26T10:31:03Z</updated>

		<summary type="html">&lt;p&gt;صفحه‌ای تازه حاوی «-- -- This module implements  --  {{Color contrast ratio}} --  {{Greater color contrast ratio}} --  {{ColorToLum}} --  {{RGBColorToLum}} --...» ایجاد کرد&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحهٔ تازه&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( 'Module:Color contrast/colors' )&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 ''&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 ''&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 ''&lt;br /&gt;
	end&lt;br /&gt;
	-- whitespace&lt;br /&gt;
	c = c:match( '^%s*(.-)[%s;]*$' )&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,'^hsl%([%s]*[0-9][0-9%.]*[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$') then&lt;br /&gt;
		local h, s, l = mw.ustring.match(c,'^hsl%([%s]*([0-9][0-9%.]*)[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$')&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,'^rgb%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*%)$') then&lt;br /&gt;
		local R, G, B = mw.ustring.match(c,'^rgb%([%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*%)$')&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,'^rgb%([%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$') then&lt;br /&gt;
		local R, G, B = mw.ustring.match(c,'^rgb%([%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$')&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, '^[%s#]*([a-f0-9]*)[%s]*$')&lt;br /&gt;
&lt;br /&gt;
	-- split into rgb&lt;br /&gt;
	local cs = mw.text.split(c or '', '')&lt;br /&gt;
	if( #cs == 6 ) then&lt;br /&gt;
		local R = 16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[2])&lt;br /&gt;
		local G = 16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[4])&lt;br /&gt;
		local B = 16*tonumber('0x' .. cs[5]) + tonumber('0x' .. 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('0x' .. cs[1]) + tonumber('0x' .. cs[1])&lt;br /&gt;
		local G = 16*tonumber('0x' .. cs[2]) + tonumber('0x' .. cs[2])&lt;br /&gt;
		local B = 16*tonumber('0x' .. cs[3]) + tonumber('0x' .. 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 ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._greatercontrast(args)&lt;br /&gt;
	local bias = tonumber(args['bias'] or '0') or 0&lt;br /&gt;
	local v1 = color2lum(args[1] or '')&lt;br /&gt;
	local c2 = args[2] or '#FFFFFF'&lt;br /&gt;
	local v2 = color2lum(c2)&lt;br /&gt;
	local c3 = args[3] or '#000000'&lt;br /&gt;
	local v3 = color2lum(c3)&lt;br /&gt;
	local ratio1 = 0;&lt;br /&gt;
	local ratio2 = 0;&lt;br /&gt;
	if (type(v1) == 'number' and type(v2) == 'number') 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) == 'number' and type(v3) == 'number') 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;
	return (ratio1 + bias &amp;gt; ratio2) and c2 or c3&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) == 'number' and type(v2) == 'number') 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['error'] or '?'&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 ''):lower()&lt;br /&gt;
	local bg, fg = 'white', 'black'&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 ~= '' 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 ~= '' 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;amp;#[Xx]23;', '#'), '&amp;amp;#35;', '#'), ';')&lt;br /&gt;
	for k = 1,#slist do&lt;br /&gt;
		s = slist[k]&lt;br /&gt;
		local k,v = s:match( '^[%s]*([^:]-):([^:]-)[%s;]*$' )&lt;br /&gt;
		k = k or ''&lt;br /&gt;
		v = v or ''&lt;br /&gt;
		if (k:match('^[%s]*(background)[%s]*$') or k:match('^[%s]*(background%-color)[%s]*$')) then&lt;br /&gt;
			local lum = color2lum(v)&lt;br /&gt;
			if( lum ~= '' ) then bg, lum_bg = v, lum end&lt;br /&gt;
		elseif (k:match('^[%s]*(color)[%s]*$')) then&lt;br /&gt;
			local lum = color2lum(v)&lt;br /&gt;
			if( lum ~= '' ) 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;
function p.lum(frame)&lt;br /&gt;
	return color2lum(frame.args[1] or frame:getParent().args[1])&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>Zamani</name></author>
		
	</entry>
</feed>