-
Notifications
You must be signed in to change notification settings - Fork 0
/
github_profile_photo_creator.py
85 lines (55 loc) · 1.93 KB
/
github_profile_photo_creator.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from PIL import Image, ImageDraw
import random
#12x12 boyutunda gibi islem yapilacak. 12*40x12*40 boyutunda
#im_frame = Image.new('RGB', (440,440), color=(240,240,240))
#iceride bloklarin yerlestirilecegi yerin çerçevesi, ilk bloklar çerçeveye
#sonra da cerceve asil görselin üstüne
#im_blok = Image.new('RGB', (80,80), color=blok_color)
#bir adet mavi blok
#blok_color = (124,203,223)
def random_color_generator():
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
return '#%02x%02x%02x' % (r,g,b)
def random_blok_list(size = 5):
r_list = []
for i in range(size):
r_list.append([])
for j in range(size):
r_list[i].append(random.randint(0,1))
return r_list
def make_image(blok_list, blok_color = '#7ccbdf', out_color = '#7cc5df'):
#blok_list = [[1,0,1,0,1],[0,1,0,1,0],[1,1,1,1,1],[0,0,1,0,0],[0,1,1,1,0]]
blok_size = 80
im_size = (len(blok_list)+1)*80
img = Image.new('RGB', (im_size,im_size), color = (240,240,240))
image = ImageDraw.Draw(img)
for i in range(len(blok_list)):
for j in range(len(blok_list)):
if blok_list[i][j] == 1:
_is = i*80+40
_js = j*80+40
shape = [(_js,_is),(_js+80,_is+80)]
image.rectangle(shape, fill = blok_color, outline = out_color)
img.show()
save = input("save? (1/0): ")
if save == "1":
return blok_list
else:
return []
make_image([[1,0,1,0,1],[0,1,0,1,0],[1,1,1,1,1],[0,0,1,0,0],[0,1,1,1,0]])
bloks = []
in_colors = []
out_colors = []
while(True):
_in = random_color_generator()
_out = random_color_generator()
new_blok = make_image(random_blok_list(), _in, _out )
if new_blok != []:
bloks.append(new_blok)
in_colors.append(_in)
out_colors.append(_out)
cont = input("Continue?: ")
if cont == "1":
break