forked from Shinonome/caelestia-cli
scheme: smart sort by hsl
Weigh hue more than others
This commit is contained in:
@@ -87,9 +87,9 @@ def grayscale(hex: str, light: bool) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def distance(colour: str, base: str) -> float:
|
def distance(colour: str, base: str) -> float:
|
||||||
r1, g1, b1 = hex_to_rgb(colour)
|
h1, l1, s1 = hex_to_hls(colour)
|
||||||
r2, g2, b2 = hex_to_rgb(base)
|
h2, l2, s2 = hex_to_hls(base)
|
||||||
return sqrt((r2 - r1) ** 2 + (g2 - g1) ** 2 + (b2 - b1) ** 2)
|
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]:
|
def smart_sort(colours: list[str], base: list[str]) -> list[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user