Last active
May 6, 2016 00:34
-
-
Save Lvl4Sword/eba31d2e12f05696789f5066d512758d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this should probably be using colorama.. | |
class my_color(object): | |
def __init__(self, first_color, second_color): | |
self.first_color = first_color | |
self.second_color = second_color | |
self.primary_colors = ['blue', 'red', 'yellow'] | |
self.secondary_colors = ['green', 'purple', 'orange'] | |
self.tertiary_colors = ['amber', 'vermillion', 'magenta', | |
'violet', 'teal', 'chartreuse'] | |
def color_magic(self, first_color, second_color): | |
if first_color == second_color: | |
print('You want to mix {0} with itself? Wut?'.format(first_color)) | |
# blue, yellow = green | |
elif all(x in [first_color, second_color] for x in self.primary_colors[0::2]): | |
return self.secondary_colors[0] | |
# blue, red = purple | |
elif all(x in [first_color, second_color] for x in self.primary_colors[0:2:1]): | |
return self.secondary_colors[1] | |
# red, yellow = orange | |
elif all(x in [first_color, second_color] for x in self.primary_colors[1:]): | |
return self.secondary_colors[2] | |
valid = False | |
while not valid: | |
first_color = input("Choose your first color (yellow/red/blue): ").lower().strip() | |
if first_color in ['blue', 'red', 'yellow']: | |
second_color = input("Choose your second color (yellow/red/blue): ").lower().strip() | |
if second_color in ['blue', 'red', 'yellow']: | |
if first_color != second_color: | |
valid = True | |
my_class = my_color(first_color, second_color) | |
combined_color = my_class.color_magic(first_color, second_color) | |
primary_text = {'blue': '\033[34m', 'red': '\033[31m', 'yellow': '\033[93m'} | |
combined_text = {'green': '\033[32m', 'orange': '\033[33m', 'purple': '\033[35m'} | |
reset_text = '\033[0m' | |
print('Combining {1}{2}{0} and {3}{4}{0} makes {5}{6}{0}!'.format(reset_text, | |
primary_text[first_color], first_color, primary_text[second_color], | |
second_color, combined_text[combined_color], combined_color)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment