View source for Module:Color
Jump to navigation
Jump to search
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
-- Introduction: https://colorspace.r-forge.r-project.org/articles/color_spaces.html
local p = {}
local function isempty(v)
return v == nil or v == ''
end
local function hexToRgb(color)
local cleanColor = color:gsub("#", "#"):match('^[%s#]*(.-)[%s;]*$')
if (#cleanColor == 6) then
return {
r = tonumber(string.sub(cleanColor, 1, 2), 16),
g = tonumber(string.sub(cleanColor, 3, 4), 16),
b = tonumber(string.sub(cleanColor, 5, 6), 16)
}
elseif (#cleanColor == 3) then
return {
r = 17 * tonumber(string.sub(cleanColor, 1, 1), 16),
g = 17 * tonumber(string.sub(cleanColor, 2, 2), 16),
b = 17 * tonumber(string.sub(cleanColor, 3, 3), 16)
}
000
1:0
Template used on this page:
Return to Module:Color.