Skip to content

Commit

Permalink
Fixed bad HSV calculation. Tag 2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
samclane committed Feb 2, 2022
1 parent de4537b commit e7e9c3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lifx_control_panel/_constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "2.2.1"
BUILD_DATE = "2022-01-30T08:19:15.782039"
VERSION = "2.2.2"
BUILD_DATE = "2022-02-02T07:01:31.052848"
AUTHOR = "Sawyer McLane"
DEBUGGING = False
2 changes: 1 addition & 1 deletion lifx_control_panel/build_all.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import datetime

bd = datetime.datetime.now().isoformat()
auth = "Sawyer McLane"
vers = "2.2.1"
vers = "2.2.2"
is_debug = False

# Write version info into _constants.py resource file
Expand Down
16 changes: 7 additions & 9 deletions lifx_control_panel/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ def __iter__(self):
TypeHSBK = Union[Tuple[int, int, int, int], Color]


def hsbk_to_rgb(hsbk: TypeHSBK) -> TypeRGB:
"""
Convert Tuple in HSBK color-space to RGB space.
Converted from PHP https://gist.github.com/joshrp/5200913
"""
def hsbk_to_rgb(hsvk: TypeHSBK) -> TypeRGB:
""" Convert Tuple in HSBK color-space to RGB space.
Converted from PHP https://gist.github.com/joshrp/5200913 """
# pylint: disable=invalid-name
iH, iS, iB, iK = hsbk
iH, iS, iV, iK = hsvk
dS = (100 * iS / 65535) / 100.0 # Saturation: 0.0-1.0
dB = (100 * iB / 65535) / 100.0 # Lightness: 0.0-1.0
dC = dB * dS # Chroma: 0.0-1.0
dV = (100 * iV / 65535) / 100.0 # Lightness: 0.0-1.0
dC = dV * dS # Chroma: 0.0-1.0
dH = (360 * iH / 65535) / 60.0 # H-prime: 0.0-6.0
dT = dH # Temp variable

Expand Down Expand Up @@ -110,7 +108,7 @@ def hsbk_to_rgb(hsbk: TypeHSBK) -> TypeRGB:
dG = 0.0
dB = 0.0

dM = dB - dC
dM = dV - dC
dR += dM
dG += dM
dB += dM
Expand Down

0 comments on commit e7e9c3b

Please sign in to comment.