-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurtains.py
More file actions
77 lines (66 loc) · 2.42 KB
/
Curtains.py
File metadata and controls
77 lines (66 loc) · 2.42 KB
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
class Curtains1:
def __init__(self, col1, col2, cT, p):
self.panel = p
self.colors = [col1, col2]
self.curCol = 0
self.startPos = 0
self.closeTime = cT * 1000
self.stamp = p.getMillis()
self.closeing = True
def incr(self):
self.startPos += 1
if (self.startPos > self.panel.width / 2):
self.startPos = 0
self.curCol += 1
if (self.curCol >= len(self.colors)):
self.curCol = 0
def reset(self):
self.curCol = 0
self.startPos = 0
self.stamp = self.panel.getMillis()
self.incrAmt = 1
def update(self):
for x in range(self.startPos):
for y in range(self.panel.height):
self.panel.setPixel(x,y,self.colors[self.curCol])
self.panel.setPixel(self.panel.width - x - 1,y,self.colors[self.curCol])
lineRate = self.closeTime / (self.panel.width/ 2.0)
if (self.panel.getMillis() - self.stamp > lineRate):
self.stamp = self.panel.getMillis()
self.incr()
class Curtains2:
def __init__(self, col1, col2, cT, p):
self.panel = p
self.colors = [col1, col2]
self.curCol = 0
self.startPos = 0
self.closeTime = cT * 1000
self.stamp = p.getMillis()
self.incrAmt = 1
def incrColor(self):
self.curCol += 1
if (self.curCol >= len(self.colors)):
self.curCol = 0
def incr(self):
self.startPos += self.incrAmt
if (self.startPos > self.panel.width / 2):
#self.incrColor()
self.incrAmt *= -1
if (self.startPos < 0):
#self.incrColor()
self.incrAmt *= -1
def reset(self):
self.curCol = 0
self.startPos = 0
self.stamp = self.panel.getMillis()
self.incrAmt = 1
def update(self):
self.panel.setBackground((0,0,0))
for x in range(self.startPos):
for y in range(self.panel.height):
self.panel.setPixel(x,y,self.colors[self.curCol])
self.panel.setPixel(self.panel.width - x - 1,y,self.colors[self.curCol])
lineRate = self.closeTime / (self.panel.width/ 2.0)
if (self.panel.getMillis() - self.stamp > lineRate):
self.stamp = self.panel.getMillis()
self.incr()