[F] Fix 3-length hex codes in Python when using custom preset (#443)

[F] Fix 3-length hex codes in Python
This commit is contained in:
thea 2025-10-10 14:46:41 +10:00 committed by GitHub
parent c722c73e79
commit f5c5e31691
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -141,9 +141,9 @@ class RGB:
g = int(hex[2:4], 16)
b = int(hex[4:6], 16)
elif len(hex) == 3:
r = int(hex[0], 16)
g = int(hex[1], 16)
b = int(hex[2], 16)
r = int(hex[0] * 2, 16)
g = int(hex[1] * 2, 16)
b = int(hex[2] * 2, 16)
else:
raise ValueError(f"Error: invalid hex length")
return cls(r, g, b)