Module:Superimpose

local main = function (args) local htmlOutput = '' if args['c1'] or args['c2'] then htmlOutput = ' ' local i = 2 while true do local c, x, y = args['c' .. i], args['x' .. i], args['y' .. i]			if c and c ~= '' then htmlOutput = ('%s %s '):format(					htmlOutput, x or 0, y or 0, c)			elseif not x and not y and not r then break end i = i + 1 end end htmlOutput = htmlOutput .. (args['c1'] or '') .. ' '	return htmlOutput end

local images = function (args) local htmlOutput = '' if args['c1'] or args['c2'] then htmlOutput = ' ' local i = 2 while true do local c, x, y, r = args['c' .. i], args['x' .. i], args['y' .. i], args['r' .. i]			if c and c ~= '' then htmlOutput = ('%s %s '):format(					htmlOutput, x or 0, y or 0, r and ('clip:rect(%spx);'):format(mw.ustring.gsub(r, ',', 'px,')) or '', c)			elseif not x and not y and not r then break end i = i + 1 end end htmlOutput = htmlOutput .. (args['c1'] or '') .. ' '	return htmlOutput end

-- lua-only, pass arguments like so: div(c1, {c2, x2, y2}, {c3, x3, y3}, ...) local div = function (c1, ...) local e = mw.html.create('span'):css('display', 'inline-block'):css('position', 'relative') for _, v in ipairs {...} do		local c, x, y = unpack(v) e:tag('span'):css('position', 'absolute'):css('padding', '0') :css('left', ('%dpx'):format(tonumber(x) or 0)):css('top', ('%dpx'):format(tonumber(y) or 0)):wikitext(c) end e:wikitext(c1) return e end

local p = require 'Module:MakeMWModule'.makeMWModule {main = main, images = images} p.div = div return p