diff options
Diffstat (limited to 'src/user_interface.py')
| -rw-r--r-- | src/user_interface.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/user_interface.py b/src/user_interface.py index f55c588..bcc5ceb 100644 --- a/src/user_interface.py +++ b/src/user_interface.py @@ -5,6 +5,7 @@ import manage_saves from rich import print + def colorPickerUI(img_path: str, num_palettes: int) -> tuple: """ display the selected color scheme and ask user if they like it @@ -14,25 +15,31 @@ def colorPickerUI(img_path: str, num_palettes: int) -> tuple: final_colors, final_compliments = selectColorsFromPalette(hex_colors, hex_compliments) return final_colors, final_compliments +def displayColors(hex_colors: list, hex_compliments: list): + constrast_levels = color_engine.checkContrast(hex_colors, hex_compliments) + main_colors = '' + complimentary_colors = '' + + for color in hex_colors: + main_colors += f'[on {color}] [/on {color}]' + print(main_colors) + for color in hex_compliments: + complimentary_colors += f'[on {color}] [/on {color}]' + print(complimentary_colors, '\n') + for i in range(len(hex_colors)): + print(f'[{hex_compliments[i]} on {hex_colors[i]}]\tGenerated Color Scheme\t\t ({i: 3})', f'contrast: {constrast_levels[i]:.2f}') + + def selectPalette(img_path: str, num_palettes: int) -> tuple: confirmed = False + hex_colors = None + hex_compliments = None while not confirmed: print() popularColors = color_engine.grabColors(img_path, num_palettes) hex_colors = color_engine.rgbToHex(popularColors) hex_compliments = color_engine.compColors(hex_colors) - constrast_levels = color_engine.checkContrast(hex_colors, hex_compliments) - main_colors = '' - complimentary_colors = '' - - for color in hex_colors: - main_colors += f'[on {color}] [/on {color}]' - print(main_colors) - for color in hex_compliments: - complimentary_colors += f'[on {color}] [/on {color}]' - print(complimentary_colors, '\n') - for i in range(len(hex_colors)): - print(f'[{hex_compliments[i]} on {hex_colors[i]}]\tGenerated Color Scheme\t\t ({i: 3})', f'contrast: {constrast_levels[i]:.2f}') + displayColors(hex_colors, hex_compliments) print('[bold](a)ccept palette (g)enerate new palette') response = input('> ') if response == 'a': @@ -43,7 +50,8 @@ def selectPalette(img_path: str, num_palettes: int) -> tuple: return hex_colors, hex_compliments -def selectColorsFromPalette(hex_colors, hex_compliments): +def selectColorsFromPalette(hex_colors: list, hex_compliments: list) -> tuple: + selectedColors = [] selected = False while not selected: print('[bold blue]Select top 3 colors from list in order Primary, Secondary, Accent (IE, "4 10 6")') @@ -55,7 +63,7 @@ def selectColorsFromPalette(hex_colors, hex_compliments): else: print('[bold red]Invalid selection. Use positive integers corresponding to color pair to select.') continue - + selectedColors = [int(i) for i in selectedColors] final_colors = [] final_compliments = [] @@ -66,10 +74,11 @@ def selectColorsFromPalette(hex_colors, hex_compliments): return final_colors, final_compliments -def pickRandomWallpaper(walls_dir) -> str: +def pickRandomWallpaper(walls_dir: str) -> str: confirmed = False history = [] num_wallpapers = len(os.listdir(walls_dir)) + wallpaper = '' while not confirmed: if len(history) == num_wallpapers: print('[bold blue] Wallpapers exhausted. Resetting history...') |
