Module:Sandbox/isaacl/ColourSpace/Formats/sRGB24bitHex

local bc = require('Module:BaseConvert') local Tuple = require('Module:Sandbox/isaacl/ColourSpace/Tuple')

local me = { }

me.infoFor = { sRGB24bitHex = { colourSpace = 'sRGB', formatType = '24bit', defaultConversion = 'sRGB24bit', parseInput = function(args) local hexCharPattern = '^#?(%x+)$' local red = string.match(args[1], hexCharPattern) local green = string.match(args[2], hexCharPattern) local blue = string.match(args[3], hexCharPattern) red = bc.convert({n = red, base = 10, from = 16}) green = bc.convert({n = green, base = 10, from = 16}) blue = bc.convert({n = blue, base = 10, from = 16}) return { red, green, blue } end, isInputFormat = function(args) local hexCharPattern = '^#%x%x?$' if ( args[3] ~= nil               and string.match(args[1], hexCharPattern)                and string.match(args[2], hexCharPattern)                and string.match(args[3], hexCharPattern) ) then return true end return false end, display = function(self, separator) local red  = string.format('&#35;%02X', self[1]) local green = string.format('&#35;%02X', self[2]) local blue = string.format('&#35;%02X', self[3]) return Tuple.display({ red, green, blue }, separator) end, mapParametersFrom = { sRGB24bit = function( colourValue ) return colourValue end, }, -- end of mapping functions }, -- info for sRGB24bitHex

sRGB24bit = { mapParametersFrom = { sRGB24bitHex = function( colourValue ) return colourValue end, }, -- end of mapping functions

}, -- conversion info from sRGB24bitHex to sRGB24bit

}

return me