Lua Utility Functions

Converts a hex string to a vector4

function hex_to_color(hex)
  local r, g, b = hex:match("#(%x%x)(%x%x)(%x%x)")
  r, g, b = tonumber(r, 16), tonumber(g, 16), tonumber(b, 16)
  return vmath.vector4(r / 255, g / 255, b / 255, 1)
end
1 Like