From 20892d9168dc678a67efcd443235fc86e8fbd834 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 9 Mar 2025 18:38:55 +1100 Subject: scheme: smart sort by hsl Weigh hue more than others --- scheme/autoadjust.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scheme/autoadjust.py') 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]: -- cgit v1.2.3-freya