Module:Sandbox/逆襲的天邪鬼/Test

From Wikipedia

Documentation for this module may be created at Module:Sandbox/逆襲的天邪鬼/Test/doc

z = {}

function z.random(frame)
	local m = frame.args[1]
	local n = frame.args[2]
	if m and n then
		return math.random(m, n)
	elseif m then
		return math.random(m)
	else
		return math.random()
	end
end

function z.test1(frame)
    local text = frame.args[1] or ''
    local n = tonumber(frame.args['n'] or 1)
    local degree = tonumber(frame.args['degree'] or 7)
    local size = tonumber(frame.args['size'] or 50)
    local delta = tonumber(frame.args['delta'] or 0)
    
    local dir = true
    local r = {}
    local fontsize = size
    
    for i = 1, n do
    	local deg = dir and '-'..degree or degree
    	dir = not dir
    	table.insert(r, '<div style="transform:rotate('..deg..'deg); -ms-transform:rotate('..deg..'deg); -moz-transform:rotate('..deg..'deg); -webkit-transform:rotate('..deg..'deg); -o-transform:rotate('..deg..'deg); font-size:'..fontsize..'px;">'..text..'</div>')
    	fontsize = fontsize + delta
    end
    
    return table.concat(r)
end

return z