From 3071725d31eacd42fc54a7b57a44304a5abfb2fb Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Fri, 31 May 2024 21:14:37 -0700 Subject: [PATCH] Rename hsl_colors -> hsl_palette Signed-off-by: Alek Ratzloff --- colorhash/palettes.py | 60 +++++++++++++++---------------- examples/commithash.svg | 80 ++++++++++++++++++++--------------------- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/colorhash/palettes.py b/colorhash/palettes.py index 7403eb8..ae97363 100644 --- a/colorhash/palettes.py +++ b/colorhash/palettes.py @@ -22,7 +22,7 @@ def quantize(r: range, steps: int = 16) -> list[float]: return [r.start + (i * dist / (steps - 1)) for i in range(steps)] -def hsl_colors(hue: HSLRange, sat: HSLRange, light: HSLRange) -> list[HSLColor]: +def hsl_palette(hue: HSLRange, sat: HSLRange, light: HSLRange) -> list[HSLColor]: """ Utility method to create 16 colors using HSL. @@ -49,7 +49,7 @@ def hsl_colors(hue: HSLRange, sat: HSLRange, light: HSLRange) -> list[HSLColor]: light = quantize(light) assert len(light) == 16, "light values must be a list of 16 elements" - return [HSLColor(round(h), round(s), round(l)) for h, s, l in zip(hue, sat, light)] + return [HSLColor(h, s, l) for h, s, l in zip(hue, sat, light)] GRADIENT_PALETTES = { @@ -70,50 +70,50 @@ GRADIENT_PALETTES = { # # Also disabling yellow-light, that one just gives me a headache. It's hard to look at. # - "red-light": hsl_colors(0, 100, range(50, 100)), - "red-dark": hsl_colors(0, 100, range(0, 50)), + "red-light": hsl_palette(0, 100, range(50, 100)), + "red-dark": hsl_palette(0, 100, range(0, 50)), # - "orange-light": hsl_colors(30, 100, range(50, 100)), - "orange-dark": hsl_colors(30, 100, range(0, 50)), + "orange-light": hsl_palette(30, 100, range(50, 100)), + "orange-dark": hsl_palette(30, 100, range(0, 50)), # - # "yellow-light": hsl_colors(60, 100, range(50, 100)), - "yellow-dark": hsl_colors(60, 100, range(0, 50)), + # "yellow-light": hsl_palette(60, 100, range(50, 100)), + "yellow-dark": hsl_palette(60, 100, range(0, 50)), # - # "lime-light": hsl_colors(90, 100, range(50, 100)), - # "lime-dark": hsl_colors(90, 100, range(0, 50)), + # "lime-light": hsl_palette(90, 100, range(50, 100)), + # "lime-dark": hsl_palette(90, 100, range(0, 50)), # - "green-light": hsl_colors(120, 100, range(50, 100)), - "green-dark": hsl_colors(120, 100, range(0, 50)), + "green-light": hsl_palette(120, 100, range(50, 100)), + "green-dark": hsl_palette(120, 100, range(0, 50)), # - # "seafoam-light": hsl_colors(150, 100, range(50, 100)), - # "seafoam-dark": hsl_colors(150, 100, range(0, 50)), + # "seafoam-light": hsl_palette(150, 100, range(50, 100)), + # "seafoam-dark": hsl_palette(150, 100, range(0, 50)), # - "cyan-light": hsl_colors(180, 100, range(50, 100)), - "cyan-dark": hsl_colors(180, 100, range(0, 50)), + "cyan-light": hsl_palette(180, 100, range(50, 100)), + "cyan-dark": hsl_palette(180, 100, range(0, 50)), # - # "teal-light": hsl_colors(210, 100, range(50, 100)), - # "teal-dark": hsl_colors(210, 100, range(0, 50)), + # "teal-light": hsl_palette(210, 100, range(50, 100)), + # "teal-dark": hsl_palette(210, 100, range(0, 50)), # - "blue-light": hsl_colors(240, 100, range(50, 100)), - "blue-dark": hsl_colors(240, 100, range(0, 50)), + "blue-light": hsl_palette(240, 100, range(50, 100)), + "blue-dark": hsl_palette(240, 100, range(0, 50)), # - "purple-light": hsl_colors(270, 100, range(50, 100)), - "purple-dark": hsl_colors(270, 100, range(0, 50)), + "purple-light": hsl_palette(270, 100, range(50, 100)), + "purple-dark": hsl_palette(270, 100, range(0, 50)), # - "magenta-light": hsl_colors(300, 100, range(50, 100)), - "magenta-dark": hsl_colors(300, 100, range(0, 50)), + "magenta-light": hsl_palette(300, 100, range(50, 100)), + "magenta-dark": hsl_palette(300, 100, range(0, 50)), # - "pink-light": hsl_colors(330, 100, range(50, 100)), - "pink-dark": hsl_colors(330, 100, range(0, 50)), + "pink-light": hsl_palette(330, 100, range(50, 100)), + "pink-dark": hsl_palette(330, 100, range(0, 50)), # - "gray-light": hsl_colors(0, 0, range(50, 100)), - "gray-dark": hsl_colors(0, 0, range(0, 50)), + "gray-light": hsl_palette(0, 0, range(50, 100)), + "gray-dark": hsl_palette(0, 0, range(0, 50)), } MULTICOLOR_PALETTES = { - "rainbow": hsl_colors(range(0, 360), 100, 50), - "rainbow-reverse": list(reversed(hsl_colors(range(0, 360), 100, 50))), + "rainbow": hsl_palette(range(0, 360), 100, 50), + "rainbow-reverse": list(reversed(hsl_palette(range(0, 360), 100, 50))), } DEFAULT_PALETTES = { diff --git a/examples/commithash.svg b/examples/commithash.svg index aa7e062..c86f5b4 100644 --- a/examples/commithash.svg +++ b/examples/commithash.svg @@ -1,42 +1,42 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file