Content deleted Content added
No edit summary |
sync |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 6:
local p = {}
local data_module = "Module:College color/data
local function stripwhitespace(text)
Line 122:
local color = '#' .. (colors[3] or colors[2] or '')
if fontcolor and fontcolor == 'auto' then
-- compute the luminosity of the background
local lum = color2lum(colors[1] or '')
-- compute the contrast with white and black
local wcontrast = (1 + 0.05)/(lum + 0.05)
local bcontrast = (lum + 0.05)/(0 + 0.05)
-- select the text color with the best contrast
if( bcontrast > wcontrast + 1.25 ) then
fontcolor = '#000000'
else
fontcolor = '#FFFFFF'
end
end
local style = 'background-color:#' .. (colors[1] or '') .. ';color:' .. (fontcolor or color) .. ';'
-- remove the border if it's nearly white
Line 139 ⟶ 152:
local color = '#' .. (colors[1] or '')
if fontcolor and fontcolor == 'auto' then
-- compute the luminosity of the background
local lum = color2lum(colors[3] or colors[2] or '')
-- compute the contrast with white and black
local wcontrast = (1 + 0.05)/(lum + 0.05)
local bcontrast = (lum + 0.05)/(0 + 0.05)
-- select the text color with the best contrast
if( bcontrast > wcontrast + 1.25 ) then
fontcolor = '#000000'
else
fontcolor = '#FFFFFF'
end
end
local style = 'background-color:#' .. (colors[3] or colors[2] or '') .. ';color:' .. (fontcolor or color) .. ';'
-- remove the border if it's nearly white
Line 234 ⟶ 260:
(colors[3] or colors[2] or 'FFFFFF'):upper()
-- now pick a font color
local fontcolor = '
-- compute the luminosity of the background
local lum = color2lum(background)
Line 242 ⟶ 268:
-- select the text color with the best contrast
if( bcontrast > wcontrast + 1.25 ) then
fontcolor = '#000000'
else
fontcolor = '#FFFFFF'
end
local s = 'background-color:#' .. background .. ';color:
if borderwidth > 0 then
local bc = (ctype == 'p') and
(colors[3] or colors[2] or '') or (colors[1] or '')
if bc ~= 'FFFFFF' then
end
end
local res = '|-
for i=1,50 do
if( args[i] ~= nil ) then
Line 324 ⟶ 349:
local r = mw.html.create('')
r:tag('span')
:addClass('legend-color')
:css('background-color', '#' .. (h or ''))
▲ :wikitext(' ')
return tostring(r)
end
Line 356 ⟶ 381:
if (#colorboxes > 0) then
return frame:extensionTag{ name = 'templatestyles', args = { src = 'Legend/styles.css'} } .. table.concat(colorboxes, sep)
end
Line 366 ⟶ 391:
local r = mw.html.create('')
r:tag('span')
:addClass('legend-color')
:css('background-color', '#' .. (h or ''))
▲ :wikitext(' ')
return tostring(r)
end
Line 428 ⟶ 453:
if (#colorboxes > 0) then
res = res .. frame:extensionTag{ name = 'templatestyles', args = { src = 'Legend/styles.css'} }
res = res .. table.concat(colorboxes, ' ')
end
|