打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

目前wiki关闭了自行注册账号的功能,如需注册账号,请查阅Help:注册账号

模块:ColorHexToDec

来自RIA | Wiki

此模块的文档可以在模块:ColorHexToDec/doc创建

local p = {}

function p.hexToDec(frame)
    local hex = frame.args[1] or "000000"
    
    hex = hex:gsub("#", "")
    
    if hex:match("^[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]$") then
        hex = hex:gsub("(.)(.)(.)", "%1%1%2%2%3%3")
    end
    
    if not hex:match("^[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]$") then
        return "000,000,000"
    end
    
    local r_hex = hex:sub(1, 2)
    local g_hex = hex:sub(3, 4)
    local b_hex = hex:sub(5, 6)
    
    local r_dec = tonumber(r_hex, 16) or 0
    local g_dec = tonumber(g_hex, 16) or 0
    local b_dec = tonumber(b_hex, 16) or 0
    
    return string.format("%d,%d,%d", r_dec, g_dec, b_dec)
end

return p