匿名
未登录
中文(中国大陆)
创建账号
登录
Limbo Wiki
搜索
这是测试站点!!!!
不要保存重要内容!不要保存重要内容!不要保存重要内容!不要保存重要内容!不要保存重要内容!
查看“︁模块:抖动”︁的源代码
来自Limbo Wiki
命名空间
模块
讨论
更多
更多
页面操作
中文(中国大陆)
阅读
查看源代码
历史
←
模块:抖动
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于这些用户组的用户执行:
管理员
、
邮箱已验证用户
、FullUser
您可以查看和复制此页面的源代码。
local p = {} -- 模式 → 类前缀 + 档位参数名 local modeDef = { ['平移'] = { pre = 'translate', levelParam = '平移幅度' }, ['旋转'] = { pre = 'rotate', levelParam = '旋转角度' }, ['跳动'] = { pre = 'bounce', levelParam = '跳动高度' }, ['摇摆'] = { pre = 'swing', levelParam = '摇摆角度' }, ['颤抖'] = { pre = 'jitter', levelParam = '颤抖幅度' }, ['缩放'] = { pre = 'pulse', levelParam = '缩放倍数' }, } -- 中文档位 → 数字档位 local cn = { ['微小'] = 1, ['极微'] = 1, ['微'] = 1, ['小'] = 2, ['较小'] = 2, ['中'] = 4, ['中等'] = 4, ['较大'] = 6, ['大'] = 6, ['特大'] = 8, ['很大'] = 8, ['巨大'] = 10, ['极大'] = 10, } -- 解析档位:数字 1~10 local function levelOf(v) if v == nil or v == '' then return 5 end if cn[v] then return cn[v] end local n = tonumber(v) if not n then return 5 end n = math.floor(n) if n < 1 then return 1 end if n > 10 then return 10 end return n end -- 模式拆分 local function splitModes(s) if not s or s == '' then return { '颤抖' } end local out, seen = {}, {} for m in mw.ustring.gmatch(s, '[^%+、,, ]+') do if modeDef[m] and not seen[m] then seen[m] = true out[#out + 1] = m end end if #out == 0 then return { '颤抖' } end return out end -- 嵌套包裹 local function wrap(inner, modes, info, perChar, idx) local html = inner for i = #modes, 1, -1 do local m = modes[i] local cls = 'dk-' .. modeDef[m].pre .. '-' .. info.levels[i] local parts = {} for _, pt in ipairs(info.styles[i]) do parts[#parts + 1] = pt end if perChar and i == 1 then -- 逐字:最外层加 shake-char,延迟改用错位相位 local filtered = {} for _, pt in ipairs(parts) do if not mw.ustring.match(pt, '^animation%-delay:') then filtered[#filtered + 1] = pt end end parts = filtered local d = string.format('%.2f', ((idx - 1) * 0.12) % 0.5) table.insert(parts, 1, 'animation-delay:-' .. d .. 's') cls = 'shake-char ' .. cls end local attr = '' if #parts > 0 then attr = ' style="' .. table.concat(parts, ';') .. '"' end html = '<span class="' .. cls .. '"' .. attr .. '>' .. html .. '</span>' end return html end function p.main(frame) local args = frame.args local text = args['内容'] or '' local perChar = (args['逐字'] or '否') == '是' local gDur, gDel = args['速度'], args['延迟'] local modes = splitModes(args['模式']) local info = { levels = {}, styles = {} } for i, m in ipairs(modes) do local def = modeDef[m] info.levels[i] = levelOf(args[def.levelParam]) local parts = {} local dur = args[m .. '速度'] if (dur == nil or dur == '') and gDur ~= nil and gDur ~= '' then dur = gDur end if dur ~= nil and dur ~= '' then parts[#parts + 1] = 'animation-duration:' .. dur .. 's' end local del = args[m .. '延迟'] if (del == nil or del == '') and gDel ~= nil and gDel ~= '' then del = gDel end if del ~= nil and del ~= '' then parts[#parts + 1] = 'animation-delay:' .. del .. 's' end info.styles[i] = parts end if perChar then -- 逐字模式:拆成单个字符(纯文本) local out, i = {}, 0 for ch in mw.ustring.gmatch(text, '.') do if ch == ' ' then out[#out + 1] = ' ' else i = i + 1 out[#out + 1] = wrap(mw.text.encode(ch), modes, info, true, i) end end return '<span class="shake-chars">' .. table.concat(out) .. '</span>' else -- 整段模式:内容作为 wikitext 解析 return wrap(frame:preprocess(text), modes, info, false, 1) end end return p
此页面嵌入的页面:
模块:抖动/doc
(
查看源代码
)
返回
模块:抖动
。
导航
导航
首页
最近更改
随机页面
操作申请
帮助
入门指南
编辑指南
写作指南
随机
官方
碎数研
谜题保管所
wiki工具
wiki工具
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志