Skip to content

Commit

Permalink
RGB colors finally take Kelvin into account. #2
Browse files Browse the repository at this point in the history
  • Loading branch information
samclane committed Jun 22, 2018
1 parent 1b976f9 commit b594b93
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ def HSBKtoRGB(hsvk: Tuple[int, int, int, int]) -> Tuple[int, int, int]:
dG += dM
dB += dM

"""
rgb_prime = int(dR * 255), int(dG * 255), int(dB * 255)
# Finally factor in Kelvin
rgb_hsb = int(dR * 255), int(dG * 255), int(dB * 255)
rgb_k = KelvinToRGB(iK)
return_rgb = tuple(int(min(255, ((dC)*a)+((1-dC)*b))) for (a, b) in zip(rgb_prime, rgb_k)) # Light model
return return_rgb
"""

return int(dR * 255), int(dG * 255), int(dB * 255)
a = iS / 65535.0
b = (1.0 - a) / 255
x = int(rgb_hsb[0] * (a + rgb_k[0] * b))
y = int(rgb_hsb[1] * (a + rgb_k[1] * b))
z = int(rgb_hsb[2] * (a + rgb_k[2] * b))
return x, y, z


def HueToRGB(h: int, s: int = 1, v: int = 1) -> Tuple[int, int, int]:
Expand Down

0 comments on commit b594b93

Please sign in to comment.