api: limit rgbhex values to 1

This commit is contained in:
shagu
2020-10-27 09:01:19 +01:00
parent 8f6d5c5989
commit 89c27f788a
+7
View File
@@ -857,6 +857,13 @@ function pfUI.api.rgbhex(r, g, b, a)
end
elseif tonumber(r) and g and b then
a = a or 1
-- limit values to 0-1
r = r + 0 > 1 and 1 or r + 0
g = g + 0 > 1 and 1 or g + 0
b = b + 0 > 1 and 1 or b + 0
a = a + 0 > 1 and 1 or a + 0
key = string.format("%s%s%s%s",r,g,b,a)
if hexcolor_cache[key] == nil then
hexcolor_cache[key] = string.format("|c%02x%02x%02x%02x", a*255, r*255, g*255, b*255)