-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path22.py
executable file
·32 lines (31 loc) · 898 Bytes
/
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
#!/usr/bin/env python
#Fact1: We're looking for color 8, as shown below. This can be found using im.getcolors() in every frame
import Image,ImageDraw
def get_vectors():
# Return a list of movement vectors extracted from wiggling pixels
im = Image.open("white.gif")
vectors=[]
try:
while True:
pix=list(im.getdata()).index(8)
y,x=divmod(pix,200)
v=(x-100,y-100)
vectors.append(v)
im.seek(im.tell()+1)
except EOFError:
pass # end of sequence
return vectors
max_x, h, w = 0, 50, 250
im = Image.new('RGB', (w,h))
draw = ImageDraw.Draw(im)
src = (max_x,h//2) # (x,y)
for v in get_vectors():
if v==(0,0):
max_x+=30
src = (max_x,h//2)
continue
dst=(src[0]+v[0],src[1]+v[1])
max_x=max(max_x,dst[0])
draw.line([src, dst], fill='white')
src=dst
im.save('22.jpg')