lua 六位数字转RGB

字符数字转RGB
六位的 如123456
七位的 如#123456
七位的有些问题 一直没时间处理

function sixNumToRGB(str_num, OutLine)
    local str_num_six
    if string.len(str_num) == 6 then
        str_num_six = str_num
    else
        str_num_six = string.sub(str_num, 1, 7)
    end

    local RGB = {}
    RGB.r = tonumber(string.sub(str_num_six, 1, 2), 16)
    RGB.g = tonumber(string.sub(str_num_six, 3, 4), 16)
    RGB.b = tonumber(string.sub(str_num_six, 5, 6), 16)

    if OutLine then
        RGB.a = OutLine
    end

    return RGB
end

猜你喜欢

转载自blog.csdn.net/qql7267/article/details/80899418
LUA