diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-28 23:04:44 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-28 23:04:44 +1100 |
| commit | 9a9fdb39a4a4a382e8021b589238c2e08619879f (patch) | |
| tree | d803d526b2195a0ec8d8126933803f724406726f /scheme/autoadjust.py | |
| parent | install: foot exec -> foot (diff) | |
| download | caelestia-cli-9a9fdb39a4a4a382e8021b589238c2e08619879f.tar.gz caelestia-cli-9a9fdb39a4a4a382e8021b589238c2e08619879f.tar.bz2 caelestia-cli-9a9fdb39a4a4a382e8021b589238c2e08619879f.zip | |
scheme: better colour generation
Pass okolors colours through material and use primary (except for mono scheme)
Mono is the same
Diffstat (limited to 'scheme/autoadjust.py')
| -rwxr-xr-x | scheme/autoadjust.py | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/scheme/autoadjust.py b/scheme/autoadjust.py index 45a90f3..9c7ea9f 100755 --- a/scheme/autoadjust.py +++ b/scheme/autoadjust.py @@ -2,7 +2,22 @@ import sys from colorsys import hls_to_rgb, rgb_to_hls -from math import sqrt + +from materialyoucolor.dynamiccolor.material_dynamic_colors import ( + DynamicScheme, + MaterialDynamicColors, +) +from materialyoucolor.hct import Hct +from materialyoucolor.scheme.scheme_content import SchemeContent +from materialyoucolor.scheme.scheme_expressive import SchemeExpressive +from materialyoucolor.scheme.scheme_fidelity import SchemeFidelity +from materialyoucolor.scheme.scheme_fruit_salad import SchemeFruitSalad +from materialyoucolor.scheme.scheme_monochrome import SchemeMonochrome +from materialyoucolor.scheme.scheme_neutral import SchemeNeutral +from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow +from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot +from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant +from materialyoucolor.utils.color_utils import argb_from_rgb light_colours = [ "dc8a78", @@ -131,17 +146,43 @@ def mix_colours(colours: list[str], base: list[str], amount: float) -> list[str] colours[i] = mix(colours[i], b, amount) +def get_scheme(scheme: str) -> DynamicScheme: + if scheme == "content": + return SchemeContent + if scheme == "expressive": + return SchemeExpressive + if scheme == "fidelity": + return SchemeFidelity + if scheme == "fruitSalad": + return SchemeFruitSalad + if scheme == "monochrome": + return SchemeMonochrome + if scheme == "neutral": + return SchemeNeutral + if scheme == "rainbow": + return SchemeRainbow + if scheme == "tonalspot": + return SchemeTonalSpot + return SchemeVibrant + + if __name__ == "__main__": light = sys.argv[1] == "light" scheme = sys.argv[2] - colours_in = sys.argv[3] if scheme == "monochrome" else sys.argv[4] + colours_in = sys.argv[3] - added_sat = 0.5 if light else 0.1 base = light_colours if light else dark_colours + MatScheme = get_scheme(scheme) colours = [] - for colour in colours_in.split(" "): - colours.append(adjust(colour, sat=added_sat)) # TODO: optional adjust + for hex in colours_in.split(" "): + if scheme == "monochrome": + colours.append(grayscale(hex, light)) + else: + argb = argb_from_rgb(int(hex[:2], 16), int(hex[2:4], 16), int(hex[4:], 16)) + mat_scheme = MatScheme(Hct.from_int(argb), not light, 0) + primary = MaterialDynamicColors.primary.get_hct(mat_scheme) + colours.append("{:02X}{:02X}{:02X}".format(*primary.to_rgba()[:3])) colours = smart_sort(colours, base) # TODO: optional smart sort @@ -151,9 +192,5 @@ if __name__ == "__main__": colours.append(mix(colours[8], base[8], 0.9)) # Success (green) colours.append(mix(colours[4], base[4], 0.9)) # Error (red) - if scheme == "monochrome": - for i, colour in enumerate(colours): - colours[i] = grayscale(colour, light) - for i, colour in enumerate(colours): print(f"{colour_names[i]} {colour}") |