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 Nov 1, 2023
1 parent ab2ffd5 commit a58cb2f
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 @@ -2253,23 +2253,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 a58cb2f

Please sign in to comment.