FANDOM


--
-- Implements [[Template:Max cape colours]]
--
 
local p = {}
local colours = require('Module:Color convert')
 
function p.main(frame)
	local args = frame:getParent().args
	local function split_colour(colour)
		local values = mw.text.split(colour,',')
		local hue = values[1]
		local sat = values[2]
		local lum = values[3]
		return {['hue']=hue,['sat']=sat,['lum']=lum}
	end
	local colour1 = split_colour(args.c1)
	local colour2 = split_colour(args.c2)
	local colour3 = split_colour(args.c3)
	local colour4 = split_colour(args.c4)
	local image = args.image or false
	local caption = args.caption or false
	local height = args.height or '130px'
	local css = args.css or ''
	return p._main{colour1,colour2,colour3,colour4,image,caption,height,css}
end
 
function p._main(...)
	local c1,c2,c3,c4,
		image,caption,
		height,css = unpack(...)
	local rt_table = mw.html.create('table')
			:addClass('wikitable')
			:css('text-align','center')
			:cssText(css)
	if caption then
		rt_table:tag('caption')
			:attr('id',caption)
			:wikitext(caption)
			:done()
	end
 
	local row1 = mw.html.create('tr')
			:tag('th'):wikitext('H'):done()
			:tag('th'):wikitext('S'):done()
			:tag('th'):wikitext('L'):done()
			:tag('th'):wikitext('H'):done()
			:tag('th'):wikitext('S'):done()
			:tag('th'):wikitext('L'):done()
	if image then
		row1:tag('td')
			:attr('rowspan',6)
			:wikitext(image)
			:done()
		:done()
	end
 
	rt_table:node(row1)
 
	rt_table:tag('tr')
		:tag('td'):wikitext(c1['hue']):done()
		:tag('td'):wikitext(c1['sat']):done()
		:tag('td'):wikitext(c1['lum']):done()
		:tag('td'):wikitext(c2['hue']):done()
		:tag('td'):wikitext(c2['sat']):done()
		:tag('td'):wikitext(c2['lum']):done()
		:done()
	:tag('tr')
		:tag('td')
			:attr('colspan','3')
			:css('background','#'..colours._jagex_to_hex(c1['hue'],c1['sat'],c1['lum']))
			:css({ width = '120px',
				height = height })
		:done()
		:tag('td')
			:attr('colspan','3')
			:css('background','#'..colours._jagex_to_hex(c2['hue'],c2['sat'],c2['lum']))
			:css({ width = '120px',
				height = height })
		:done()
	:done()
	:tag('tr')
		:tag('th'):wikitext('H'):done()
		:tag('th'):wikitext('S'):done()
		:tag('th'):wikitext('L'):done()
		:tag('th'):wikitext('H'):done()
		:tag('th'):wikitext('S'):done()
		:tag('th'):wikitext('L'):done()
	:done()
	:tag('tr')
		:tag('td'):wikitext(c3['hue']):done()
		:tag('td'):wikitext(c3['sat']):done()
		:tag('td'):wikitext(c3['lum']):done()
		:tag('td'):wikitext(c4['hue']):done()
		:tag('td'):wikitext(c4['sat']):done()
		:tag('td'):wikitext(c4['lum']):done()
		:done()
	:tag('tr')
		:tag('td')
			:attr('colspan','3')
			:css('background','#'..colours._jagex_to_hex(c3['hue'],c3['sat'],c3['lum']))
			:css({ width = '120px',
				height = height })
		:done()
		:tag('td')
			:attr('colspan','3')
			:css('background','#'..colours._jagex_to_hex(c4['hue'],c4['sat'],c4['lum']))
			:css({ width = '120px',
				height = height })
		:done()
	:done()
 
	return rt_table
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.