Module:Sprite: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 2: Line 2:


p.main = function( frame )
p.main = function( frame )
return "Hello, world!"
local ratio = tonumber(frame.args['ratio'])
local sheetWidth = tonumber(frame.args['sheetWidth'])
local sheetHeight = tonumber(frame.args['sheetHeight'])
local noOfRows = tonumber(frame.args['noOfRows'])
local noOfColumns = tonumber(frame.args['noOfColumns'])
local cellWidth = sheetWidth / noOfRows
local cellHeight = sheetHeight / noOfColumns
local outerSpan = mw.html.create('span')
outerSpan
:css({
position = 'relative',
height = tostring(cellHeight * ratio) .. 'px',
width = tostring(cellWidth * ratio) .. 'px',
overflow = 'hidden',
display = 'inline-block',
['vertical-align'] = 'middle'
})
return tostring(outerSpan)
end
end


return p
return p