Create a new color-palette
This commit is contained in:
parent
b80f8ab09a
commit
fc5673be9a
1 changed files with 34 additions and 0 deletions
34
.local/bin/color-palette-new
Executable file
34
.local/bin/color-palette-new
Executable file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# This file's name matches the CLI convention in ~/.local/bin
|
||||||
|
# pylint: disable=invalid-name
|
||||||
|
|
||||||
|
# Templates for six consumers live here
|
||||||
|
# => Length of file is managable
|
||||||
|
# pylint: disable=too-many-lines
|
||||||
|
|
||||||
|
"""Derive a color palette from GNOME's accent color.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def hexify(
|
||||||
|
*,
|
||||||
|
lightness: float,
|
||||||
|
chroma: float,
|
||||||
|
hue: float,
|
||||||
|
) -> str:
|
||||||
|
"""Convert an "oklch" color to a lower-case sRGB hex string.
|
||||||
|
|
||||||
|
OKLCH can describe colors that sRGB cannot display,
|
||||||
|
mostly dark ones with high chroma. Such colors are made displayable
|
||||||
|
by reducing only their chroma (i.e., toward gray) until they
|
||||||
|
just fit into sRGB, keeping lightness and hue as requested.
|
||||||
|
So, a fitted stop is exactly as dark and exactly
|
||||||
|
in the anchor's hue as designed, just a little less colorful.
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
coloraide.Color("oklch", (lightness, chroma, hue))
|
||||||
|
.convert("srgb")
|
||||||
|
.fit(method="oklch-chroma")
|
||||||
|
.to_string(hex=True, upper=False)
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue