Skip to content

match cpython #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions colorsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def hls_to_rgb(hue: float, light: float, sat: float) -> Tuple[float, float, floa
chroma2 = light + sat - (light * sat)
chroma1 = 2.0 * light - chroma2
return (
int(_v(chroma1, chroma2, hue + ONE_THIRD) * 255),
int(_v(chroma1, chroma2, hue) * 255),
int(_v(chroma1, chroma2, hue - ONE_THIRD) * 255),
_v(chroma1, chroma2, hue + ONE_THIRD),
_v(chroma1, chroma2, hue),
_v(chroma1, chroma2, hue - ONE_THIRD),
)


Expand Down Expand Up @@ -101,15 +101,14 @@ def hsv_to_rgb( # pylint: disable=too-many-return-statements,inconsistent-retur
chroma3 = val * (1.0 - sat * (1.0 - hue1))
i = i % 6
if i == 0:
return int(val * 255), int(chroma3 * 255), int(chroma1 * 255)
return val, chroma3, chroma1
if i == 1:
return int(chroma2 * 255), int(val * 255), int(chroma1 * 255)
return chroma2, val, chroma1
if i == 2:
return int(chroma1 * 255), int(val * 255), int(chroma3 * 255)
return chroma1, val, chroma3
if i == 3:
return int(chroma1 * 255), int(chroma2 * 255), int(val * 255)
return chroma1, chroma2, val
if i == 4:
return int(chroma3 * 255), int(chroma1 * 255), int(val * 255)
return chroma3, chroma1, val
if i == 5:
return int(val * 255), int(chroma1 * 255), int(chroma2 * 255)
# Cannot get here
return val, chroma1, chroma2