summaryrefslogtreecommitdiff
path: root/src/user_interface.py
diff options
context:
space:
mode:
authorChandler J <cjustice2000@gmail.com>2024-04-12 20:54:00 -0600
committerGitHub <noreply@github.com>2024-04-12 20:54:00 -0600
commit8a1903bb16d9e04795c33f3eb226486d06e8a642 (patch)
treee8fc9dc0bb690cc1976a47fe1166f4bafcafcb40 /src/user_interface.py
parent95e73b141ca8f3618701ff59658ef519353cc7c0 (diff)
parent2564189a769a5bd3de63086bb62dc3532d1b07b9 (diff)
Merge branch 'main' into saves
Diffstat (limited to 'src/user_interface.py')
-rw-r--r--src/user_interface.py39
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...')