summaryrefslogtreecommitdiff
path: root/src/user_interface.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/user_interface.py')
-rw-r--r--src/user_interface.py40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/user_interface.py b/src/user_interface.py
index 934098c..4162d1e 100644
--- a/src/user_interface.py
+++ b/src/user_interface.py
@@ -4,32 +4,42 @@ import color_engine
from rich import print
-def colorPickerUI(img_path: str, num_palettes: int) -> tuple:
+def colorPickerUI(img_path: str, num_palettes: int, saved_colors = None) -> tuple:
#display the selected color scheme and ask user if they like it or want to generate a new color scheme
- hex_colors, hex_compliments = selectPalette(img_path, num_palettes)
+ if saved_colors == None:
+ hex_colors, hex_compliments = selectPalette(img_path, num_palettes)
+ else:
+ hex_colors, hex_compliments = saved_colors
+ print(f'[bold green] colors successfully loaded from file')
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':