Module:Sprite: Difference between revisions
Jump to navigation
Jump to search
Auburnsummer (talk | contribs) No edit summary |
Auburnsummer (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
p.main = function( frame ) | p.main = function( frame ) | ||
return | 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 |
Revision as of 08:08, 27 May 2022
Documentation for this module may be created at Module:Sprite/doc
local p = {}
p.main = function( frame )
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
return p