From 89c27f788aa092ad403dd4bf740a8ba017810ce1 Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 27 Oct 2020 09:01:19 +0100 Subject: [PATCH] api: limit rgbhex values to 1 --- api/api.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/api.lua b/api/api.lua index d6d1e3fe..802dd858 100644 --- a/api/api.lua +++ b/api/api.lua @@ -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)