diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-09 18:38:55 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-09 18:38:55 +1100 |
| commit | 20892d9168dc678a67efcd443235fc86e8fbd834 (patch) | |
| tree | 3b2244b15e70529ce5a80949c5849066784bfa97 /scheme/autoadjust.py | |
| parent | format (diff) | |
| download | caelestia-cli-20892d9168dc678a67efcd443235fc86e8fbd834.tar.gz caelestia-cli-20892d9168dc678a67efcd443235fc86e8fbd834.tar.bz2 caelestia-cli-20892d9168dc678a67efcd443235fc86e8fbd834.zip | |
scheme: smart sort by hsl
Weigh hue more than others
Diffstat (limited to 'scheme/autoadjust.py')
| -rwxr-xr-x | scheme/autoadjust.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/scheme/autoadjust.py b/scheme/autoadjust.py index 4b29ac1..45a90f3 100755 --- a/scheme/autoadjust.py +++ b/scheme/autoadjust.py @@ -87,9 +87,9 @@ def grayscale(hex: str, light: bool) -> str: def distance(colour: str, base: str) -> float: - r1, g1, b1 = hex_to_rgb(colour) - r2, g2, b2 = hex_to_rgb(base) - return sqrt((r2 - r1) ** 2 + (g2 - g1) ** 2 + (b2 - b1) ** 2) + h1, l1, s1 = hex_to_hls(colour) + h2, l2, s2 = hex_to_hls(base) + return abs(h1 - h2) * 0.4 + abs(l1 - l2) * 0.3 + abs(s1 - s2) * 0.3 def smart_sort(colours: list[str], base: list[str]) -> list[str]: |