Vital.sandbox
String

string.parse_hex

Shared

Converts a hexadecimal color string to RGB values


Syntax

local r, g, b = string.parse_hex(input)

Parameters

TypeNameDescription
stringinputHexadecimal color string - with or without # prefix

Returns

TypeNameDescription
intrRed component (0-255)
intgGreen component (0-255)
intbBlue component (0-255)

Examples

--Parse hex color with # prefix
local r, g, b = string.parse_hex("#FF5733")
engine.print(r, g, b) --255  87  51
--Parse hex color without # prefix
local r, g, b = string.parse_hex("00FF00")
engine.print(r, g, b) --0  255  0

On this page