-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitShower.py
101 lines (69 loc) · 2.24 KB
/
twitShower.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import pygame
import time
import glob
import os
from random import choice
import urllib
def mtime(filename):
return os.stat(filename).st_mtime
def get_random_img(path, resolution):
good_img = False
while(not good_img):
try:
img = choice(get_files(path))
image = pygame.image.load( img )
image = pygame.transform.smoothscale( image, resolution)
good_img = True
except(KeyboardInterrupt):
exit(0)
except:
pass
text_content = img.replace(path, "")
text_content = text_content[:text_content.find("/")]
text_content = urllib.unquote_plus(text_content)
return image, text_content
def get_files(path):
biglist = []
baselist = sorted(glob.glob(path+'*'), key=mtime, reverse=True)
for path in baselist:
for img_file in sorted(glob.glob(path+"/*"), key=mtime):
biglist.append(img_file)
return biglist
def main():
pygame.init()
resolution = pygame.display.list_modes()[0]
screen = pygame.display.set_mode( resolution, pygame.FULLSCREEN|pygame.HWSURFACE|pygame.HWACCEL )
background = pygame.Surface( screen.get_size() )
background.fill( (0,0,0) )
image, text_content = get_random_img('./images/', resolution)
screen.blit( background, (0,0) )
screen.blit( image, (0,0) )
pygame.display.flip()
colora = (0,0,0)
colorb = (255,255,255)
rounds = 0
while 1:
pygame.event.pump()
keyinput = pygame.key.get_pressed()
if keyinput[pygame.K_ESCAPE] or pygame.event.peek( pygame.QUIT ):
break
screen.blit( background, (0,0) )
screen.blit( image, (0,0) )
font = pygame.font.Font(None, 60)
temp = colora
colora = colorb
colorb = temp
text = font.render(text_content, 1, colora)
screen.blit(text, (100,100))
screen.blit(text, (110,110))
screen.blit(text, (110,100))
screen.blit(text, (100,110))
text = font.render(text_content, 1, colorb)
screen.blit(text, (105,105))
pygame.display.flip()
rounds += 1
if rounds == 20:
image, text_content = get_random_img('./images/',resolution)
rounds = 0
time.sleep(0.1)
if __name__ == '__main__': main()