Module:Sprite: Difference between revisions
Auburnsummer (talk | contribs) No edit summary |
Auburnsummer (talk | contribs) No edit summary |
||
| (26 intermediate revisions by the same user not shown) | |||
| Line 11: | Line 11: | ||
local row = tonumber(frame.args['row']) - 1 | local row = tonumber(frame.args['row']) - 1 | ||
local col = tonumber(frame.args['col']) - 1 | local col = tonumber(frame.args['col']) - 1 | ||
local cellWidth = sheetWidth / | local image = frame.args['image'] | ||
local cellHeight = sheetHeight / | local cellWidth = sheetWidth / noOfColumns | ||
local cellHeight = sheetHeight / noOfRows | |||
local outline = frame:getArgument('outline') | |||
local imageClass | |||
if outline ~= nil then | |||
imageClass = "pixelart blackstroke" | |||
else | |||
imageClass = "pixelart" | |||
end | |||
local span = mw.html.create('span') | local span = mw.html.create('span') | ||
: | :cssText( | ||
position | string.format( | ||
[[ | |||
position: relative; | |||
height: %dpx; | |||
width: %dpx; | |||
overflow: hidden; | |||
display: inline-block; | |||
vertical-align: middle; | |||
]], | |||
cellHeight * ratio, | |||
cellWidth * ratio | |||
) | |||
) | |||
:tag('span') | :tag('span') | ||
: | :cssText( | ||
position | string.format( | ||
[[ | |||
position: absolute; | |||
height: %dpx; | |||
width: %dpx; | |||
top: %dpx; | |||
left: %dpx; | |||
]], | |||
sheetHeight * ratio, | |||
sheetWidth * ratio, | |||
(offsetY - cellHeight * row) * ratio, | |||
(offsetX - cellWidth * col) * ratio | |||
) | |||
) | |||
:wikitext(string.format('[[%s|%dpx|class=pixelart]]', image, sheetWidth * ratio)) | |||
:done() | :done() | ||
return tostring(span) | return tostring(span) | ||