feat: funcion now correctly converts decimal rgb to hex

This commit is contained in:
Sandro Zimmermann 2026-04-03 15:53:43 +02:00
parent e09a44dcd1
commit dae045562b

View File

@ -1,2 +1,11 @@
def rgb(r, g, b):
pass
rgb = {"r": int(r), "g": int(g), "b": int(b)}
for decimal in rgb:
rgb[decimal] = min(255, max(rgb[decimal], 0))
rgb[decimal] = hex(rgb[decimal]).split("x")[-1]
if len(rgb[decimal]) == 1:
rgb[decimal] = "0" + rgb[decimal]
return f"{rgb['r']}{rgb['g']}{rgb['b']}".upper()