diff --git a/src/caelestia/utils/material/__init__.py b/src/caelestia/utils/material/__init__.py index 88e855f..b9aabab 100644 --- a/src/caelestia/utils/material/__init__.py +++ b/src/caelestia/utils/material/__init__.py @@ -31,7 +31,7 @@ def get_colours_for_image(image: Path | str = wallpaper_thumbnail_path, scheme=N scheme = get_scheme() cache_base = scheme_cache_dir / compute_hash(image) - cache = (cache_base / scheme.variant / scheme.mode).with_suffix(".json") + cache = (cache_base / scheme.variant / scheme.flavour / scheme.mode).with_suffix(".json") try: with cache.open("r") as f: diff --git a/src/caelestia/utils/material/generator.py b/src/caelestia/utils/material/generator.py index 9337257..a8de4e2 100644 --- a/src/caelestia/utils/material/generator.py +++ b/src/caelestia/utils/material/generator.py @@ -142,7 +142,7 @@ def lighten(colour: Hct, amount: float) -> Hct: def darken(colour: Hct, amount: float) -> Hct: diff = colour.tone * amount - return Hct.from_hct(colour.hue, colour.chroma + diff / 5, colour.tone - diff) + return Hct.from_hct(colour.hue, colour.chroma - diff / 5, colour.tone - diff) def get_scheme(scheme: str) -> DynamicScheme: @@ -216,6 +216,12 @@ def gen_scheme(scheme, primary: Hct) -> dict[str, str]: for name, hct in colours.items(): colours[name].chroma -= 15 + # Darken surfaces for hard flavour + if scheme.flavour == "hard": + for colour in "background", *(k for k in colours.keys() if k.startswith("surface")): + colours[colour] = lighten(colours[colour], 0.4) if light else darken(colours[colour], 0.8) + colours["term0"] = lighten(colours["term0"], 0.4) if light else darken(colours["term0"], 0.9) + # FIXME: deprecated stuff colours["text"] = colours["onBackground"] colours["subtext1"] = colours["onSurfaceVariant"] @@ -230,6 +236,18 @@ def gen_scheme(scheme, primary: Hct) -> dict[str, str]: colours["mantle"] = darken(colours["surface"], 0.03) colours["crust"] = darken(colours["surface"], 0.05) + # More darkening if hard flavour + if scheme.flavour == "hard": + for colour in "base", "mantle", "crust": + colours[colour] = lighten(colours[colour], 0.4) if light else darken(colours[colour], 0.9) + for i in range(3): + colours[f"overlay{i}"] = ( + lighten(colours[f"overlay{i}"], 0.4) if light else darken(colours[f"overlay{i}"], 0.8) + ) + colours[f"surface{i}"] = ( + lighten(colours[f"surface{i}"], 0.4) if light else darken(colours[f"surface{i}"], 0.8) + ) + # For debugging # print("\n".join(["{}: \x1b[48;2;{};{};{}m \x1b[0m".format(n, *c.to_rgba()[:3]) for n, c in colours.items()])) diff --git a/src/caelestia/utils/scheme.py b/src/caelestia/utils/scheme.py index 31fb77a..57a5e0b 100644 --- a/src/caelestia/utils/scheme.py +++ b/src/caelestia/utils/scheme.py @@ -229,7 +229,9 @@ def get_scheme_flavours(name: str = None) -> list[str]: if name is None: name = get_scheme().name - return ["default"] if name == "dynamic" else [f.name for f in (scheme_data_dir / name).iterdir() if f.is_dir()] + return ( + ["default", "hard"] if name == "dynamic" else [f.name for f in (scheme_data_dir / name).iterdir() if f.is_dir()] + ) def get_scheme_modes(name: str = None, flavour: str = None) -> list[str]: diff --git a/src/caelestia/utils/wallpaper.py b/src/caelestia/utils/wallpaper.py index 327da5c..5564db6 100644 --- a/src/caelestia/utils/wallpaper.py +++ b/src/caelestia/utils/wallpaper.py @@ -106,7 +106,7 @@ def get_colours_for_wall(wall: Path | str, no_smart: bool) -> None: scheme = Scheme( { "name": name, - "flavour": "default", + "flavour": scheme.flavour, "mode": smart_opts["mode"], "variant": smart_opts["variant"], "colours": scheme.colours, @@ -115,7 +115,7 @@ def get_colours_for_wall(wall: Path | str, no_smart: bool) -> None: return { "name": name, - "flavour": "default", + "flavour": scheme.flavour, "mode": scheme.mode, "variant": scheme.variant, "colours": get_colours_for_image(get_thumb(wall, cache), scheme),