hoodini.utils.colors
Color utility helpers.
1"""Color utility helpers.""" 2 3from __future__ import annotations 4 5 6def desaturate(hex_color: str, amount: float = 0.2) -> str: 7 hex_color = hex_color.lstrip("#") 8 rgb = [int(hex_color[i : i + 2], 16) for i in (0, 2, 4)] 9 rgb = [int(c + (255 - c) * amount) for c in rgb] 10 return "#" + "".join(f"{c:02x}" for c in rgb) 11 12 13def darken(hex_color: str, amount: float = 0.2) -> str: 14 hex_color = hex_color.lstrip("#") 15 rgb = [int(hex_color[i : i + 2], 16) for i in (0, 2, 4)] 16 rgb = [int(c * (1 - amount)) for c in rgb] 17 return "#" + "".join(f"{c:02x}" for c in rgb)
def
desaturate(hex_color: str, amount: float = 0.2) -> str:
def
darken(hex_color: str, amount: float = 0.2) -> str: