Fixed saturation overflow in --sat tweak. Fixes #59

This commit is contained in:
Vladyslav Hroshev
2025-04-24 09:05:03 +03:00
parent 419a8d36ba
commit 407aaf9c52
3 changed files with 39 additions and 3 deletions

View File

@@ -23,8 +23,7 @@ class ColorReplacementGenerator:
lightness = int(color_def["l"]) / 100
saturation = int(color_def["s"]) / 100
if theme_color.saturation is not None:
saturation *= theme_color.saturation / 100
saturation = self._adjust_saturation(saturation, theme_color)
alpha = color_def["a"]
red, green, blue = self.color_converter.hsl_to_rgb(
@@ -33,6 +32,15 @@ class ColorReplacementGenerator:
return f"rgba({red}, {green}, {blue}, {alpha})"
@staticmethod
def _adjust_saturation(base_saturation: float, theme_color: InstallationColor) -> float:
"""Adjust saturation based on the theme color"""
if theme_color.saturation is None:
return base_saturation
adjusted = base_saturation * (theme_color.saturation / 100)
return min(adjusted, 1.0)
def _get_color_definition(self, element: str, mode: str) -> dict:
"""Get color definition for element, handling defaults if needed"""
replacer = self.colors.replacers[element]