Skip to content

Commit fc664b5

Browse files
committed
Start adding type hints to this file
1 parent 6a6b888 commit fc664b5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

images/chunky_pixels.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import tqdm
1515

1616

17-
def clamp(x, *, between):
17+
def clamp(x: float, /, *, between: tuple[int, int]) -> float:
18+
"""
19+
Restrict the value to fit between the lower/upper bounds.
20+
"""
1821
lower, upper = between
1922
return min([max([x, lower]), upper])
2023

@@ -55,8 +58,8 @@ def clamp(x, *, between):
5558

5659
for (x_start, y_start), (r, g, b) in all_colours.items():
5760
hue, lightness, saturation = colorsys.rgb_to_hls(r / 255, g / 255, b / 255)
58-
lightness = clamp(lightness * random.uniform(0.9, 1.1), between=[0, 1])
59-
saturation = clamp(saturation * random.uniform(0.9, 1.1), between=[0, 1])
61+
lightness = clamp(lightness * random.uniform(0.9, 1.1), between=(0, 1))
62+
saturation = clamp(saturation * random.uniform(0.9, 1.1), between=(0, 1))
6063

6164
r, g, b = colorsys.hls_to_rgb(hue, lightness, saturation)
6265
draw.rectangle(

0 commit comments

Comments
 (0)