mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Prevent division by 0 xy->rgb color conversion
This commit is contained in:
parent
d9b30d1421
commit
586be7fad1
@ -53,8 +53,12 @@ def color_xy_brightness_to_RGB(vX, vY, brightness):
|
||||
return (0, 0, 0)
|
||||
|
||||
Y = brightness
|
||||
X = (Y / vY) * vX
|
||||
Z = (Y / vY) * (1 - vX - vY)
|
||||
if vY != 0:
|
||||
X = (Y / vY) * vX
|
||||
Z = (Y / vY) * (1 - vX - vY)
|
||||
else:
|
||||
X = 0
|
||||
Z = 0
|
||||
|
||||
# Convert to RGB using Wide RGB D65 conversion.
|
||||
r = X * 1.612 - Y * 0.203 - Z * 0.302
|
||||
|
Loading…
x
Reference in New Issue
Block a user