Skip to content

Commit

Permalink
hashception!
Browse files Browse the repository at this point in the history
(Jokes aside, we tend to prefer that syntatcit sugar (and string
methods) as opposed to calling string.fn(obj) explicitly).
  • Loading branch information
NiLuJe committed Jan 21, 2024
1 parent 4ac0eba commit 73ac82b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ffi/blitbuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2329,23 +2329,23 @@ return a Color value resembling a given hex string
function BB.colorFromString(value)
value = value:gsub('#','')
-- #rrggbbaa
if(string.len(value) == 8) then
if(#value == 8) then
return ColorRGB32(
tonumber(value:sub(1,2), 16),
tonumber(value:sub(3,4), 16),
tonumber(value:sub(5,6), 16),
tonumber(value:sub(7,8), 16)
)
-- #rrggbb
elseif(string.len(value) == 6) then
elseif(#value == 6) then
return ColorRGB32(
tonumber(value:sub(1,2), 16),
tonumber(value:sub(3,4), 16),
tonumber(value:sub(5,6), 16),
0xFF
)
-- #vv
elseif(string.len(value) == 2) then
elseif(#value == 2) then
return ColorRGB32(
tonumber(value:sub(1,2), 16),
tonumber(value:sub(1,2), 16),
Expand Down

0 comments on commit 73ac82b

Please sign in to comment.