-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreensaver.py
54 lines (34 loc) · 1.11 KB
/
screensaver.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
"""
screensaver.py - some interesting effects
author : Benjamin Blundell
email : [email protected]
"""
from buffergame import BufferGame, loadFromFile
class FileToBuffer(BufferGame):
''' A basic bit of text '''
def __init__(self, boardX = 14, boardY = 13, filename="crashburn.txt"):
super(FileToBuffer,self).__init__(boardX,boardY)
self.playhead = 0
self.currentFrame = 0
data = loadFromFile(boardX, boardY, filename)
self.frames = data["buffers"]
self.timeLength = data["duration"]
# Set first frame
self.copyBuffer(self.frames[0]["buffer"])
def frame(self,fps=2):
dt = 1/fps
self.playhead += dt
if self.playhead > self.timeLength :
self.playhead = 0 # loop back to the beginning
self.copyBuffer(self.frames[0]["buffer"])
self.currentFrame = 0
return
tt = 0
idx = 0
for idx in range(0,len(self.frames)):
tt += self.frames[idx]["time"]
if tt >= self.playhead:
if idx > self.currentFrame:
self.copyBuffer(self.frames[idx]["buffer"])
self.currentFrame = idx
return