-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcolorGenerator.py
More file actions
36 lines (30 loc) · 846 Bytes
/
colorGenerator.py
File metadata and controls
36 lines (30 loc) · 846 Bytes
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
from PIL import Image
COLORS = {
"default": (221, 127, 33),
"red": (207, 6, 0),
"green": (23, 195, 43),
"blue": (39, 137, 228),
"orange": (221, 127, 33),
"yellow": (212, 169, 19),
"pink": (236, 89, 131),
"purple": (123, 28, 168),
"white": (204, 204, 204),
"black": (25, 25, 25),
"gray": (102, 102, 102),
"brown": (76, 29, 0),
"cyan": (70, 192, 181),
"acid": (142, 194, 40),
}
def generateImage(color: str):
if color.startswith("#"):
cidx = int(color[1:], 16)
rgb = (cidx // (256**2), (cidx // 256)%256 , cidx % 256)
elif " " in color:
rgb = [int(i) for i in color.split(" ")]
rgb = tuple(rgb)
elif color in COLORS.keys():
rgb = COLORS[color]
else:
return None
img = Image.new("RGB", (1024, 256), rgb)
return img