summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-06-23 20:58:48 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-06-23 20:58:48 +1000
commitdbfb92569447133300fe73d1214bdc42933aa716 (patch)
tree29a93e1c90766942df71a1c613351e7af1283027
parent[CI] emojis: update data (diff)
downloadcaelestia-cli-dbfb92569447133300fe73d1214bdc42933aa716.tar.gz
caelestia-cli-dbfb92569447133300fe73d1214bdc42933aa716.tar.bz2
caelestia-cli-dbfb92569447133300fe73d1214bdc42933aa716.zip
score: fix for low contrast wallpapers
-rw-r--r--src/caelestia/utils/material/score.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/caelestia/utils/material/score.py b/src/caelestia/utils/material/score.py
index 7765050..6599b90 100644
--- a/src/caelestia/utils/material/score.py
+++ b/src/caelestia/utils/material/score.py
@@ -20,7 +20,7 @@ class Score:
pass
@staticmethod
- def score(colors_to_population: dict, filter_enabled: bool = True) -> tuple[list[Hct], list[Hct]]:
+ def score(colors_to_population: dict, filter_enabled: bool = False) -> tuple[list[Hct], list[Hct]]:
desired = 14
dislike_filter = True
@@ -62,7 +62,7 @@ class Score:
# Choose distinct colours
chosen_colors = []
- for difference_degrees_ in range(90, 0, -1):
+ for difference_degrees_ in range(90, -1, -1):
chosen_colors.clear()
for item in scored_hct:
hct = item["hct"]
@@ -78,7 +78,7 @@ class Score:
# Get primary colour
primary = None
- for cutoff in range(20, 0, -1):
+ for cutoff in range(20, -1, -1):
for item in scored_hct:
if item["hct"].chroma > cutoff and item["hct"].tone > cutoff * 3:
primary = item["hct"]
@@ -86,6 +86,10 @@ class Score:
if primary:
break
+ # Ensure primary exists
+ if not primary:
+ return Score.score(colors_to_population, False)
+
# Choose distinct primaries
chosen_primaries = [primary]
for difference_degrees_ in range(90, 14, -1):