diff options
| author | Chandler J <cjustice2000@gmail.com> | 2024-04-12 20:44:47 -0600 |
|---|---|---|
| committer | Chandler J <cjustice2000@gmail.com> | 2024-04-12 20:44:47 -0600 |
| commit | 95e73b141ca8f3618701ff59658ef519353cc7c0 (patch) | |
| tree | 27967d34376bc6ed624c12c758f580a712765118 /src/color_engine.py | |
| parent | b7dc1316ab0eb51f408b2b7782571d868ad3b864 (diff) | |
major changes:
- Can now save/load themes which entails the color scheme and
wallpaper
- Can now use themes to load colors independent of background image
- refactoring to make code less bad
Diffstat (limited to 'src/color_engine.py')
| -rw-r--r-- | src/color_engine.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/color_engine.py b/src/color_engine.py index 0e43475..bcb3ba2 100644 --- a/src/color_engine.py +++ b/src/color_engine.py @@ -26,9 +26,9 @@ def compColors(color_list: list) -> list: """ compliments = [] for color in color_list: - curr_hex = color[1:] # slice off the # from the hex code + curr_hex = color[1:] rgb = (curr_hex[0:2], curr_hex[2:4], curr_hex[4:6]) - comp = ['%02X' % (255 - int(a, 16)) for a in rgb] # magic :D + comp = ['%02X' % (255 - int(a, 16)) for a in rgb] compliments.append('#' + ''.join(comp)) return compliments @@ -54,7 +54,7 @@ def checkContrast(hex_color_list: list, hex_compliment_list: list) -> list: def relativeLuminance(color: list): - threshold = 0.03928 # this whole function is magic constants lol + threshold = 0.03928 channels = [] for channel in color: @@ -70,7 +70,6 @@ def relativeLuminance(color: list): return luminance - def rgbToHex(input_values: list) -> list: """ Takes in a list of RBG color values and returns a list of those same colors as hex values @@ -83,6 +82,7 @@ def rgbToHex(input_values: list) -> list: hex_list.append('#{:02x}{:02x}{:02x}'.format(red, green, blue)) return hex_list + def hexToRGB(hex_value: str) -> tuple: """ Takes in a list of Hex values and returns a tuple of those colors as rgb values @@ -90,6 +90,7 @@ def hexToRGB(hex_value: str) -> tuple: hex_value = hex_value.lstrip('#') return tuple(int(hex_value[i:i+2], 16) for i in (0, 2, 4)) # Magic :DDDDDD + def hexToRGB_list(hex_list: list) -> list: colors = [] for color in hex_list: |
