×
Create a new article
Write your page title here:
We currently have 2,528 articles on Polcompball Wiki. Type your article name above or click on one of the titles below and start writing!



Polcompball Wiki

Module:Hex2rgb: Difference between revisions

imported>TheGhostOfInky
(Created page with "local utils = {} function utils.hex2rgb(frame) local hex = frame.args[1] or frame:getParent().args[1] if hex:sub(1,1) == "#" then a = tostring(tonumber(h...")
 
imported>Denatidum
(Created page with "local utils = {} function utils.hex2rgb(frame) local hex = frame.args[1] or frame:getParent().args[1] if hex:sub(1,1) == "#" then a = tostring(tonumber(h...")
 
(No difference)

Latest revision as of 07:32, 25 June 2021

Documentation for this module may be created at Module:Hex2rgb/doc

local utils = {}

function utils.hex2rgb(frame)
    local hex = frame.args[1] or frame:getParent().args[1]
    
    if hex:sub(1,1) == "#" then
        a = tostring(tonumber(hex:sub(2, 3), 16))
        b = tostring(tonumber(hex:sub(4, 5), 16))
        c = tostring(tonumber(hex:sub(6, 7), 16))
    else
        a = tostring(tonumber(hex:sub(1, 2), 16))
        b = tostring(tonumber(hex:sub(3, 4), 16))
        c = tostring(tonumber(hex:sub(5, 6), 16))
    end
    return a.. ", " .. b .. ", " .. c
end

return utils