[+] Encapsulate set_light and lighten

This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-06-19 17:37:04 -04:00
parent 1c67333b45
commit b46d0e96f4
2 changed files with 26 additions and 7 deletions

View file

@ -17,7 +17,6 @@ class ColorProfile:
else:
self.colors = colors
def with_weights(self, weights: list[int]) -> list[RGB]:
"""
Map colors based on weights
@ -76,11 +75,29 @@ class ColorProfile:
result += '\033[0m'
result += t
else:
result += colors[i].to_ansi_rgb(foreground) + t
result += colors[i].to_ansi(foreground=foreground) + t
result += '\033[0m'
return result
def lighten(self, multiplier: float) -> ColorProfile:
"""
Lighten the color profile by a multiplier
:param multiplier: Multiplier
:return: Lightened color profile (original isn't modified)
"""
return ColorProfile([c.lighten(multiplier) for c in self.colors])
def set_light(self, light: int):
"""
Set HSL lightness value
:param light: Lightness value
:return: New color profile (original isn't modified)
"""
return ColorProfile([c.set_light(light) for c in self.colors])
PRESETS: dict[str, ColorProfile] = {
'rainbow': ColorProfile([