Documentation for this module may be created at Module:Prismatic dyes/doc
-- <pre>
local p = {}
local colors = mw.loadData('Module:Prismatic dyes/data')
local convert = require('Module:Color convert')
function p.main()
local ret = mw.html.create('table')
:css('border-spacing','3px')
for _, v in ipairs(colors) do
local new_row
new_row = ret:tag('tr')
:tag('td')
:attr('rowspan','4')
:attr('title',getTitle(v[1][4]))
:css({ background = getRGB(v[1][4]),
height = '100px',
width = '100px',
['box-shadow'] = '1px 1px 3px #999',
['border-radius'] = '8px' })
:done()
for i, w in ipairs(v) do
for _, x in ipairs(w) do
new_row :tag('td')
:attr('title',getTitle(x))
:css({ background = getRGB(x),
height = '25px',
width = '25px',
['box-shadow'] = '1px 1px 3px #999',
['border-radius'] = '4px' })
:done()
end
new_row:done()
if i < 4 then
new_row = ret:tag('tr')
end
end
ret :tag('tr')
:tag('th')
:attr('colspan','5')
:done()
:done()
end
return ret
end
function getRGB(tbl)
local r,g,b = tbl[1],tbl[2],tbl[3]
return string.format('rgb(%s,%s,%s)',r,g,b)
end
function getTitle(tbl)
local r,g,b = tbl[1],tbl[2],tbl[3]
local hr,hg,hb = unpack(convert._rgb_to_hex(r,g,b))
return string.format('Red: %s; Green: %s; Blue: %s | Hex: #%s%s%s',r,g,b,hr,hg,hb)
end
return p