{{#invoke:Superimpose|main |c1= |c2= |x2= |y2= |c3= |x3= |y3= ...}}
c1
: Base contentc2, c3, c4 ...
: Content to overlay, add as many as neededx2, x3, x4 ...
: In pixels, x coordinatey2, y3, y4 ...
: In pixels, y coordinate
{{#invoke:Superimpose|images |c1= |c2= |x2= |y2= |r2= |c3= |x3= |y3= |r3= ...}}
r2, r3, r4 ...
: In pixels, clip region (e.g.2,98,98,2
)
Example[]
{{#invoke:Superimpose|main |c1=[[File:Fir_Sword_Student_Face.png|300x300px|link=Fir: Sword Student|alt=Fir: Sword Student]] |c2=[[File:Icon_Class_Red_Sword.png|50x50px|link=File:Icon_Class_Red_Sword.png|alt=]] |x2=100 |y2=50 |c3=[[File:Icon_Move_Infantry.png|50x50px|link=File:Icon_Class_Red_Sword.png|alt=]] |x3=150 |y3=100}}
The above documentation is transcluded from Module:Superimpose/doc. (edit | history)
local main = function (args)
local htmlOutput = ''
if args['c1'] or args['c2'] then
htmlOutput = '<span style="display:inline-block;position:relative;">'
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<span style="position:absolute;left:%spx;top:%spx;padding:0;">%s</span>'):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 '') .. '</span>'
return htmlOutput
end
local images = function (args)
local htmlOutput = ''
if args['c1'] or args['c2'] then
htmlOutput = '<span style="display:inline-block;position:relative;line-height:1">'
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<span style="position:absolute;left:%spx;top:%spx;%spadding:0;">%s</span>'):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 '') .. '</span>'
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