-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.py
59 lines (48 loc) · 1.71 KB
/
color.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from enum import Enum
from PIL import ImageColor
import random
clear = ImageColor.getrgb('#ffffff')
class ColorLayers(Enum):
red = 0
blue = 1
white = 2
black = 3
orange = 4
purp = 5
dgreen = 6
lgreen = 7
burg = 8
def get_color_from_color_layer(color_layer):
if color_layer == ColorLayers.red:
return ImageColor.getrgb('#DE5A51')
elif color_layer == ColorLayers.blue:
return ImageColor.getrgb('#61CDF5')
elif color_layer == ColorLayers.white:
return ImageColor.getrgb('#F2F1ED')
elif color_layer == ColorLayers.black:
return ImageColor.getrgb('#050505')
elif color_layer == ColorLayers.orange:
return ImageColor.getrgb('#E66643')
elif color_layer == ColorLayers.purp:
return ImageColor.getrgb('#5B32B2')
elif color_layer == ColorLayers.dgreen:
return ImageColor.getrgb('#4E8B61')
elif color_layer == ColorLayers.lgreen:
return ImageColor.getrgb('#77DD77')
elif color_layer == ColorLayers.burg:
return ImageColor.getrgb('#520519')
def contrasting_colors(color_layer, contrast_against=None):
if contrast_against is None:
return [c for c in list(ColorLayers) if c != color_layer]
else:
return [c for c in contrast_against if c != color_layer]
def get_random_contrasting_color(color_layer=None, contrast_against=None):
if contrast_against is None:
#print('in here')
contrast_against = list(ColorLayers)
if color_layer is None:
return random.choice(contrast_against)
else:
return random.choice(contrasting_colors(color_layer, contrast_against))
def get_random_sample(num, ommit=None):
return random.sample(list(ColorLayers), num)