- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14.py
More file actions
Latest commit
54 lines (49 loc) · 1.24 KB
/
Copy path14.py
File metadata and controls
54 lines (49 loc) · 1.24 KB
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
fromPILimportImage
fromPILimportImageDraw
im=Image.open("wire/wire.png")
result=Image.new("RGB", (100, 100), "white")
drawer=ImageDraw.Draw(result)
im_size=im.size
im_x=im_size[0]
im_y=im_size[1]
result_size=result.size
result_x=result_size[0]
result_y=result_size[1]
count=0
x=0
y=0
len_x=result_x
len_y=result_y
whiley<len_y:
whilex<len_x:
# print("x={}, y={}, count={}".format(x, y, count))
drawer.point((x, y), im.getpixel((count,0)))
x+=1
count+=1
x-=1
len_x-=1
y+=1
whiley<len_y:
# print("x={}, y={}, count={}".format(x, y, count))
drawer.point((x, y), im.getpixel((count,0)))
y+=1
count+=1
y-=1
len_y-=1
x-=1
whilex>=result_x-len_x-1:
# print("x={}, y={}, count={}".format(x, y, count))
drawer.point((x, y), im.getpixel((count,0)))
x-=1
count+=1
x+=1
y-=1
whiley>=result_y-len_y:
# print("x={}, y={}, count={}, result_y={}, len_y={}".format(x, y, count, result_y, len_y))
drawer.point((x, y), im.getpixel((count,0)))
y-=1
count+=1
y+=1
x+=1
result.show()
result.save("wire/cat.png")