Rename hsl_colors -> hsl_palette

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-05-31 21:14:37 -07:00
parent 6086f5a46d
commit 3071725d31
2 changed files with 70 additions and 70 deletions

View File

@@ -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 = {

View File

@@ -1,42 +1,42 @@
<svg width="256" height="160" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="32" height="32" fill="hsl(330.00,100.00%,23.00%)" />
<rect x="32" y="0" width="32" height="32" fill="hsl(330.00,100.00%,7.00%)" />
<rect x="64" y="0" width="32" height="32" fill="hsl(330.00,100.00%,13.00%)" />
<rect x="96" y="0" width="32" height="32" fill="hsl(330.00,100.00%,30.00%)" />
<rect x="128" y="0" width="32" height="32" fill="hsl(330.00,100.00%,33.00%)" />
<rect x="160" y="0" width="32" height="32" fill="hsl(330.00,100.00%,37.00%)" />
<rect x="192" y="0" width="32" height="32" fill="hsl(330.00,100.00%,10.00%)" />
<rect x="224" y="0" width="32" height="32" fill="hsl(330.00,100.00%,40.00%)" />
<rect x="0" y="32" width="32" height="32" fill="hsl(330.00,100.00%,50.00%)" />
<rect x="32" y="32" width="32" height="32" fill="hsl(330.00,100.00%,50.00%)" />
<rect x="64" y="32" width="32" height="32" fill="hsl(330.00,100.00%,0.00%)" />
<rect x="96" y="32" width="32" height="32" fill="hsl(330.00,100.00%,23.00%)" />
<rect x="128" y="32" width="32" height="32" fill="hsl(330.00,100.00%,0.00%)" />
<rect x="160" y="32" width="32" height="32" fill="hsl(330.00,100.00%,27.00%)" />
<rect x="192" y="32" width="32" height="32" fill="hsl(330.00,100.00%,7.00%)" />
<rect x="224" y="32" width="32" height="32" fill="hsl(330.00,100.00%,47.00%)" />
<rect x="0" y="64" width="32" height="32" fill="hsl(330.00,100.00%,0.00%)" />
<rect x="32" y="64" width="32" height="32" fill="hsl(330.00,100.00%,27.00%)" />
<rect x="64" y="64" width="32" height="32" fill="hsl(330.00,100.00%,3.00%)" />
<rect x="96" y="64" width="32" height="32" fill="hsl(330.00,100.00%,37.00%)" />
<rect x="128" y="64" width="32" height="32" fill="hsl(330.00,100.00%,43.00%)" />
<rect x="160" y="64" width="32" height="32" fill="hsl(330.00,100.00%,23.00%)" />
<rect x="192" y="64" width="32" height="32" fill="hsl(330.00,100.00%,23.00%)" />
<rect x="224" y="64" width="32" height="32" fill="hsl(330.00,100.00%,47.00%)" />
<rect x="0" y="96" width="32" height="32" fill="hsl(330.00,100.00%,40.00%)" />
<rect x="32" y="96" width="32" height="32" fill="hsl(330.00,100.00%,50.00%)" />
<rect x="64" y="96" width="32" height="32" fill="hsl(330.00,100.00%,7.00%)" />
<rect x="96" y="96" width="32" height="32" fill="hsl(330.00,100.00%,37.00%)" />
<rect x="128" y="96" width="32" height="32" fill="hsl(330.00,100.00%,47.00%)" />
<rect x="160" y="96" width="32" height="32" fill="hsl(330.00,100.00%,33.00%)" />
<rect x="192" y="96" width="32" height="32" fill="hsl(330.00,100.00%,50.00%)" />
<rect x="224" y="96" width="32" height="32" fill="hsl(330.00,100.00%,3.00%)" />
<rect x="0" y="128" width="32" height="32" fill="hsl(330.00,100.00%,3.00%)" />
<rect x="32" y="128" width="32" height="32" fill="hsl(330.00,100.00%,0.00%)" />
<rect x="64" y="128" width="32" height="32" fill="hsl(330.00,100.00%,27.00%)" />
<rect x="96" y="128" width="32" height="32" fill="hsl(330.00,100.00%,37.00%)" />
<rect x="128" y="128" width="32" height="32" fill="hsl(330.00,100.00%,43.00%)" />
<rect x="160" y="128" width="32" height="32" fill="hsl(330.00,100.00%,50.00%)" />
<rect x="192" y="128" width="32" height="32" fill="hsl(330.00,100.00%,23.00%)" />
<rect x="224" y="128" width="32" height="32" fill="hsl(330.00,100.00%,30.00%)" />
<rect x="0" y="0" width="32" height="32" fill="hsl(270.00,100.00%,70.00%)" />
<rect x="32" y="0" width="32" height="32" fill="hsl(270.00,100.00%,50.00%)" />
<rect x="64" y="0" width="32" height="32" fill="hsl(270.00,100.00%,76.67%)" />
<rect x="96" y="0" width="32" height="32" fill="hsl(270.00,100.00%,70.00%)" />
<rect x="128" y="0" width="32" height="32" fill="hsl(270.00,100.00%,100.00%)" />
<rect x="160" y="0" width="32" height="32" fill="hsl(270.00,100.00%,66.67%)" />
<rect x="192" y="0" width="32" height="32" fill="hsl(270.00,100.00%,83.33%)" />
<rect x="224" y="0" width="32" height="32" fill="hsl(270.00,100.00%,63.33%)" />
<rect x="0" y="32" width="32" height="32" fill="hsl(270.00,100.00%,70.00%)" />
<rect x="32" y="32" width="32" height="32" fill="hsl(270.00,100.00%,93.33%)" />
<rect x="64" y="32" width="32" height="32" fill="hsl(270.00,100.00%,56.67%)" />
<rect x="96" y="32" width="32" height="32" fill="hsl(270.00,100.00%,63.33%)" />
<rect x="128" y="32" width="32" height="32" fill="hsl(270.00,100.00%,80.00%)" />
<rect x="160" y="32" width="32" height="32" fill="hsl(270.00,100.00%,66.67%)" />
<rect x="192" y="32" width="32" height="32" fill="hsl(270.00,100.00%,70.00%)" />
<rect x="224" y="32" width="32" height="32" fill="hsl(270.00,100.00%,90.00%)" />
<rect x="0" y="64" width="32" height="32" fill="hsl(270.00,100.00%,83.33%)" />
<rect x="32" y="64" width="32" height="32" fill="hsl(270.00,100.00%,66.67%)" />
<rect x="64" y="64" width="32" height="32" fill="hsl(270.00,100.00%,73.33%)" />
<rect x="96" y="64" width="32" height="32" fill="hsl(270.00,100.00%,76.67%)" />
<rect x="128" y="64" width="32" height="32" fill="hsl(270.00,100.00%,56.67%)" />
<rect x="160" y="64" width="32" height="32" fill="hsl(270.00,100.00%,73.33%)" />
<rect x="192" y="64" width="32" height="32" fill="hsl(270.00,100.00%,60.00%)" />
<rect x="224" y="64" width="32" height="32" fill="hsl(270.00,100.00%,50.00%)" />
<rect x="0" y="96" width="32" height="32" fill="hsl(270.00,100.00%,96.67%)" />
<rect x="32" y="96" width="32" height="32" fill="hsl(270.00,100.00%,63.33%)" />
<rect x="64" y="96" width="32" height="32" fill="hsl(270.00,100.00%,70.00%)" />
<rect x="96" y="96" width="32" height="32" fill="hsl(270.00,100.00%,80.00%)" />
<rect x="128" y="96" width="32" height="32" fill="hsl(270.00,100.00%,76.67%)" />
<rect x="160" y="96" width="32" height="32" fill="hsl(270.00,100.00%,86.67%)" />
<rect x="192" y="96" width="32" height="32" fill="hsl(270.00,100.00%,100.00%)" />
<rect x="224" y="96" width="32" height="32" fill="hsl(270.00,100.00%,93.33%)" />
<rect x="0" y="128" width="32" height="32" fill="hsl(270.00,100.00%,53.33%)" />
<rect x="32" y="128" width="32" height="32" fill="hsl(270.00,100.00%,50.00%)" />
<rect x="64" y="128" width="32" height="32" fill="hsl(270.00,100.00%,83.33%)" />
<rect x="96" y="128" width="32" height="32" fill="hsl(270.00,100.00%,63.33%)" />
<rect x="128" y="128" width="32" height="32" fill="hsl(270.00,100.00%,100.00%)" />
<rect x="160" y="128" width="32" height="32" fill="hsl(270.00,100.00%,90.00%)" />
<rect x="192" y="128" width="32" height="32" fill="hsl(270.00,100.00%,66.67%)" />
<rect x="224" y="128" width="32" height="32" fill="hsl(270.00,100.00%,56.67%)" />
</svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB