summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-03-28 23:04:44 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-03-28 23:04:44 +1100
commit9a9fdb39a4a4a382e8021b589238c2e08619879f (patch)
treed803d526b2195a0ec8d8126933803f724406726f
parentinstall: foot exec -> foot (diff)
downloadcaelestia-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
-rwxr-xr-xscheme/autoadjust.py55
-rwxr-xr-xscheme/gen-scheme.fish9
2 files changed, 48 insertions, 16 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}")
diff --git a/scheme/gen-scheme.fish b/scheme/gen-scheme.fish
index 4e82882..22751fa 100755
--- a/scheme/gen-scheme.fish
+++ b/scheme/gen-scheme.fish
@@ -7,19 +7,14 @@ set -l src (dirname (status filename))
test -f "$argv[1]" && set -l img (realpath "$argv[1]") || set -l img $C_STATE/wallpaper/thumbnail.jpg
contains -- "$argv[2]" light dark && set -l theme $argv[2] || set -l theme dark
-set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content
+set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome
# Generate colours
-test $theme = light && set -l lightness 50 || set -l lightness 70
-set -l colours (okolors $img -k 14 -w 0 -l $lightness)
+set -l colours (okolors $img -k 14)
for variant in $variants
mkdir -p $src/../data/schemes/dynamic/$variant
$src/autoadjust.py $theme $variant $colours > $src/../data/schemes/dynamic/$variant/$theme.txt
end
-mkdir -p $src/../data/schemes/dynamic/monochrome
-$src/autoadjust.py $theme monochrome (okolors $img -k 14) > $src/../data/schemes/dynamic/monochrome/$theme.txt
-
-set -la variants monochrome
# Generate layers and accents
set -l tmp (mktemp)