-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path22.py
62 lines (54 loc) · 2.66 KB
/
22.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
from PIL import Image
from PIL import ImageSequence
import turtle, time
def main():
file_path = "copper/white.gif"
pixels = first_step(file_path)
"""
pixels = [(100, 100), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102),
(100, 102), (102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100),
(102, 100), (102, 98), (100, 98), (100, 98), (100, 98), (98, 98), (98, 100), (98, 100), (98, 100),
(98, 100), (98, 100), (98, 100), (98, 102), (100, 100), (98, 98), (98, 98), (98, 100), (98, 100),
(98, 100), (98, 100), (98, 100), (98, 102), (98, 102), (98, 102), (100, 102), (100, 102), (102, 102),
(102, 102), (102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 98), (102, 98),
(102, 98), (100, 98), (100, 98), (100, 100), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102),
(100, 102), (100, 102), (102, 100), (100, 98), (100, 98), (100, 98), (102, 98), (102, 98), (102, 98),
(102, 98), (102, 100), (102, 100), (102, 102), (102, 102), (102, 102), (100, 102), (100, 102), (100, 102),
(100, 102), (100, 100), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102),
(102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 98), (100, 98),
(100, 98), (100, 98), (100, 98), (100, 98), (100, 98), (100, 100), (98, 98), (98, 100), (98, 100),
(98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 102), (100, 102), (100, 102), (102, 102),
(102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 102),
(100, 102), (100, 102), (98, 102), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100),
(98, 100), (98, 98)]
"""
second_step(pixels)
def first_step(file_path):
im = Image.open(file_path)
pixels = []
for frame in ImageSequence.Iterator(im):
size = frame.size
width = size[0]
height = size[1]
for x in range(width):
for y in range(height):
pixel = frame.getpixel((x, y))
if pixel != 0:
pixels.append((x, y))
print(pixels)
return pixels
def second_step(pixels):
EXP = 10
x = y = 0
for pilx, pily in pixels:
dx = (pilx - 100) // 2
dy = (100 - pily) // 2
x += dx * EXP
y += dy * EXP
turtle.goto(x, y)
if dx == dy == 0:
time.sleep(1)
turtle.reset()
x = y = 0
if __name__ == "__main__":
main()