forked from osresearch/LEDscape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentify
executable file
·39 lines (31 loc) · 931 Bytes
/
identify
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
#!/usr/bin/python
# Draw an image with PIl that has the coordinates
# in flashing colors
#
import Image, ImageFont, ImageDraw
import socket
import time, datetime
from colorsys import hsv_to_rgb
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dest = ("localhost", 9999)
#print im.format, im.size, im.mode
# use a truetype font
font = ImageFont.truetype("pf_tempesta_seven.ttf", 8)
i = 0
width = 256
height = 64
disp = Image.new("RGB", (width,height), "black")
disp_draw = ImageDraw.Draw(disp)
def rainbow(i):
rgb = [int(x*256) for x in hsv_to_rgb(i/256.0,0.8,0.8)]
return (rgb[0],rgb[1],rgb[2])
while True:
disp.paste("black", (0,0,width,height))
for x in range(0,width, 32):
for y in range(0,height, 16):
s = str(x) + "," + str(y)
disp_draw.text((x+2, y), s, font=font, fill=rainbow(i))
# Send it to the drawing server
sock.sendto(chr(1) + disp.tostring(), dest)
i = (i+1) % width
time.sleep(0.025)