About: USERAPI HexToRGB   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Takes a hex string (must be 3 or 6 chars long!) and converts it to a RGB set (0-255). If hex is invalid, return black (0,0,0). local function HexToRGB(hex) local rhex, ghex, bhex if strlen(hex) == 6 then rhex, ghex, bhex = strmatch('([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})', hex) elseif strlen(hex) == 3 then rhex, ghex, bhex = strmatch('([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])', hex) if rhex and ghex and bhex then rhex = rhex .. rhex ghex = ghex .. ghex bhex = bhex .. bhex end end if not (rhex and ghex and bhex) then return 0, 0, 0 else return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16) end end

AttributesValues
rdfs:label
  • USERAPI HexToRGB
rdfs:comment
  • Takes a hex string (must be 3 or 6 chars long!) and converts it to a RGB set (0-255). If hex is invalid, return black (0,0,0). local function HexToRGB(hex) local rhex, ghex, bhex if strlen(hex) == 6 then rhex, ghex, bhex = strmatch('([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})', hex) elseif strlen(hex) == 3 then rhex, ghex, bhex = strmatch('([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])', hex) if rhex and ghex and bhex then rhex = rhex .. rhex ghex = ghex .. ghex bhex = bhex .. bhex end end if not (rhex and ghex and bhex) then return 0, 0, 0 else return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16) end end
dbkwik:wowwiki/pro...iPageUsesTemplate
abstract
  • Takes a hex string (must be 3 or 6 chars long!) and converts it to a RGB set (0-255). If hex is invalid, return black (0,0,0). local function HexToRGB(hex) local rhex, ghex, bhex if strlen(hex) == 6 then rhex, ghex, bhex = strmatch('([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})', hex) elseif strlen(hex) == 3 then rhex, ghex, bhex = strmatch('([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])', hex) if rhex and ghex and bhex then rhex = rhex .. rhex ghex = ghex .. ghex bhex = bhex .. bhex end end if not (rhex and ghex and bhex) then return 0, 0, 0 else return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16) end end
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software