This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local utils = {} | |
| --- Converts a hex color string to rgb/rgba values | |
| --- @param hexColor string | |
| --- @param asFraction? boolean | |
| function utils.hexToRgb(hexColor, asFraction) | |
| if (not utils.isValidHexColor(hexColor)) then error("Invalid hex color string: " .. hexColor) end | |
| local parse = function(f, t) | |
| local value = tonumber("0x" .. hexColor:sub(f, t or f)) * (t and 1 or 17) | |
| return (asFraction and value / 255) or value |