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