diff options
Diffstat (limited to 'src/color_engine.py')
| -rw-r--r-- | src/color_engine.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/color_engine.py b/src/color_engine.py index 7a177fb..504e84b 100644 --- a/src/color_engine.py +++ b/src/color_engine.py @@ -24,9 +24,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 @@ -50,6 +50,7 @@ def checkContrast(hex_color_list: list, hex_compliment_list: list) -> list: return contrast_values + def relativeLuminance(color: list) -> float: """ Determines the luminance of color. The luminance allows us to @@ -76,7 +77,6 @@ def relativeLuminance(color: list) -> float: 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 @@ -89,6 +89,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 @@ -96,6 +97,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)) + def hexToRGB_list(hex_list: list) -> list: colors = [] for color in hex_list: |
