-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmultiwall_image_display.py
executable file
·63 lines (52 loc) · 1.44 KB
/
multiwall_image_display.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Image
from acabsl import send
from acabsl import update
import colorsys
import random
import time
import sys, os, glob
# more is faster
rotation_speed = 1.5
rounds_per_image = 3
directory = '.'
wall_count=2
rows=6
cols=8
def blank_walls():
for col in range(cols):
for row in range(rows):
for wall in range(wall_count):
send(col,row,0,0,0,0,wall);
update()
def render_frame(wall, image_data, angle):
ptr = 0
for y in range(rows):
for x in range(cols):
x += angle
x = x % cols
if type(image_data[ptr]) == int:
send(x,y,image_data[ptr],image_data[ptr],image_data[ptr],0,wall);
else:
send(x,y,image_data[ptr][0],image_data[ptr][1],image_data[ptr][2],0,wall);
ptr += 1
update()
def display_image(img):
# initialize the wall
blank_walls()
for repeats in range(rounds_per_image):
image_raw_data = img.resize((cols,rows)).getdata()
for angle in range(cols):
render_frame(0, image_raw_data, angle)
render_frame(1, image_raw_data, angle)
time.sleep(1/rotation_speed)
# let's find all images in the image directory and then
# shuffle the list to choose one randomly
image_list = []
for ext in ('jpg', 'jpeg', 'bmp', 'png', 'gif'):
search_str = os.path.join(directory,'*.{0}'.format(ext))
image_list.extend(glob.glob(search_str))
random.shuffle(image_list)
im = Image.open(image_list[0])
display_image(im)