Module:Sprite: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 7: Line 7:
local noOfRows = tonumber(frame.args['noOfRows'])
local noOfRows = tonumber(frame.args['noOfRows'])
local noOfColumns = tonumber(frame.args['noOfColumns'])
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 cellWidth = sheetWidth / noOfRows
local cellWidth = sheetWidth / noOfRows
local cellHeight = sheetHeight / noOfColumns
local cellHeight = sheetHeight / noOfColumns
Line 21: Line 25:
:tag('span')
:tag('span')
:css({
:css({
position = 'absolute'
position = 'absolute',
height = tostring(sheetHeight * ratio) .. 'px',
width = tostring(sheetWidth * ratio) .. 'px',
top = (offsetY - cellHeight * row) * ratio,
left = (offsetX - cellWidth * row) * ratio
})
})
:done()
:done()