From 95e73b141ca8f3618701ff59658ef519353cc7c0 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Fri, 12 Apr 2024 20:44:47 -0600 Subject: 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 --- src/color_engine.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/color_engine.py') 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: -- cgit v1.2.3