Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit b56df60

Browse files
Inf-inityInf-inity
Inf-inity
authored and
Inf-inity
committed
.
1 parent 70646d3 commit b56df60

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

general/color_picker/cog.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222

2323
def _to_floats(given: list[COLOR_ARGS]) -> tuple[float, float, float]:
24+
"""
25+
takes a list with tuples containing a value and a max_values
26+
at the end it should return a number between 0 and 1 for each tuple
27+
"""
2428
out: list[float] = []
2529

2630
for arg in given:
@@ -57,12 +61,14 @@ async def color_picker(self, ctx: Context, *, color: str):
5761
rgb = _to_floats([COLOR_ARGS(color_re.group(i), 255) for i in range(2, 5)])
5862

5963
elif color_re := self.RE_HSV.match(color):
60-
values = _to_floats([COLOR_ARGS(color_re.group(i[0]), i[1]) for i in ((2, 360), (3, 100), (4, 100))])
61-
rgb = colorsys.hsv_to_rgb(values[0], values[1], values[2])
64+
rgb = colorsys.hsv_to_rgb(
65+
*_to_floats([COLOR_ARGS(color_re.group(i), value) for i, value in ((2, 360), (3, 100), (4, 100))])
66+
)
6267

6368
elif color_re := self.RE_HSL.match(color):
64-
values = _to_floats([COLOR_ARGS(color_re.group(i[0]), i[1]) for i in ((2, 360), (3, 100), (4, 100))])
65-
rgb = colorsys.hls_to_rgb(values[0], values[2], values[1])
69+
rgb = colorsys.hls_to_rgb(
70+
*_to_floats([COLOR_ARGS(color_re.group(i), value) for i, value in ((2, 360), (3, 100), (4, 100))])
71+
)
6672

6773
else:
6874
raise CommandError(t.error.parse_color_example(color))

0 commit comments

Comments
 (0)