From 2564189a769a5bd3de63086bb62dc3532d1b07b9 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Sat, 6 Apr 2024 21:53:25 -0600 Subject: added menubutton bind for i3, refactoring --- src/color_engine.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/color_engine.py') diff --git a/src/color_engine.py b/src/color_engine.py index c24450b..7a177fb 100644 --- a/src/color_engine.py +++ b/src/color_engine.py @@ -50,9 +50,17 @@ def checkContrast(hex_color_list: list, hex_compliment_list: list) -> list: return contrast_values -def relativeLuminance(color: list): - - threshold = 0.03928 # this whole function is magic constants lol +def relativeLuminance(color: list) -> float: + """ + Determines the luminance of color. The luminance allows us to + compute the contrast between two colors by comparing their + relative luminance. + + The magic constants in this function are all taken from the following + description of relative luminance: + https://www.w3.org/TR/WCAG20/#relativeluminancedef + """ + threshold = 0.03928 channels = [] for channel in color: @@ -86,12 +94,12 @@ def hexToRGB(hex_value: str) -> tuple: Takes in a list of Hex values and returns a tuple of those colors as rgb values """ hex_value = hex_value.lstrip('#') - return tuple(int(hex_value[i:i+2], 16) for i in (0, 2, 4)) # Magic :DDDDDD + 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: hex_value = color.lstrip('#') - colors.append(tuple(int(hex_value[i:i+2], 16) for i in (0, 2, 4))) # Magic :DDDDDD + colors.append(tuple(int(hex_value[i:i+2], 16) for i in (0, 2, 4))) return colors -- cgit v1.2.3