Skip to content

Instantly share code, notes, and snippets.

@cxmeel
Created February 12, 2023 18:52
Show Gist options
  • Save cxmeel/7065a4bc21f7c69018ae628e1eb946e8 to your computer and use it in GitHub Desktop.
Save cxmeel/7065a4bc21f7c69018ae628e1eb946e8 to your computer and use it in GitHub Desktop.
local function parseImageString(imageString: string)
local contentId = imageString:match("(%w+://%S+)")
local width = tonumber(select(1, imageString:match("[wW](%d+)")))
local height = tonumber(select(1, imageString:match("[hH](%d+)")))
local x = tonumber(select(1, imageString:match("[xX](%d+)")))
local y = tonumber(select(1, imageString:match("[yY](%d+)")))
local color = imageString:match("(#%x+)")
local transparency = tonumber(select(1, imageString:match("(%d+)%%")))
return {
Image = contentId,
ImageRectSize = (width and height) and Vector2.new(width, height),
ImageRectOffset = (x and y) and Vector2.new(x, y),
ImageColor3 = color and Color3.fromHex(color),
ImageTransparency = transparency and transparency / 100,
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment