This commit is contained in:
Zacharias-Brohn
2026-03-05 16:34:35 +01:00
parent 467fdc5e5e
commit de91e36228
+22 -22
View File
@@ -67,6 +67,14 @@ def generate(
TEMPLATE_DIR = Path(HOME + "/.config/zshell/templates") TEMPLATE_DIR = Path(HOME + "/.config/zshell/templates")
WALL_PATH = Path() WALL_PATH = Path()
def hex_to_hct(hex_color: str) -> Hct:
s = hex_color.strip()
if s.startswith("#"):
s = s[1:]
if len(s) != 6:
raise ValueError(f"Expected 6-digit hex color, got: {hex_color!r}")
return Hct.from_int(int("0xFF" + s, 16))
LIGHT_GRUVBOX = list( LIGHT_GRUVBOX = list(
map( map(
hex_to_hct, hex_to_hct,
@@ -119,30 +127,22 @@ def generate(
path = json.load(f)["currentWallpaperPath"] path = json.load(f)["currentWallpaperPath"]
WALL_PATH = path WALL_PATH = path
def hex_to_hct(hex_color: str) -> Hct: def lighten(color: Hct, amount: float) -> Hct:
s = hex_color.strip() diff = (100 - color.tone) * amount
if s.startswith("#"): tone = max(0.0, min(100.0, color.tone + diff))
s = s[1:] chroma = max(0.0, color.chroma + diff / 5)
if len(s) != 6: return Hct.from_hct(color.hue, chroma, tone)
raise ValueError(f"Expected 6-digit hex color, got: {hex_color!r}")
return Hct.from_int(int("0xFF" + s, 16))
def lighten(colour: Hct, amount: float) -> Hct: def darken(color: Hct, amount: float) -> Hct:
diff = (100 - colour.tone) * amount diff = color.tone * amount
tone = max(0.0, min(100.0, colour.tone + diff)) tone = max(0.0, min(100.0, color.tone - diff))
chroma = max(0.0, colour.chroma + diff / 5) chroma = max(0.0, color.chroma - diff / 5)
return Hct.from_hct(colour.hue, chroma, tone) return Hct.from_hct(color.hue, chroma, tone)
def darken(colour: Hct, amount: float) -> Hct: def grayscale(color: Hct, light: bool) -> Hct:
diff = colour.tone * amount color = darken(color, 0.35) if light else lighten(color, 0.65)
tone = max(0.0, min(100.0, colour.tone - diff)) color.chroma = 0
chroma = max(0.0, colour.chroma - diff / 5) return color
return Hct.from_hct(colour.hue, chroma, tone)
def grayscale(colour: Hct, light: bool) -> Hct:
colour = darken(colour, 0.35) if light else lighten(colour, 0.65)
colour.chroma = 0
return colour
def harmonize(from_hct: Hct, to_hct: Hct, tone_boost: float) -> Hct: def harmonize(from_hct: Hct, to_hct: Hct, tone_boost: float) -> Hct:
diff = difference_degrees(from_hct.hue, to_hct.hue) diff = difference_degrees(from_hct.hue, to_hct.hue)