-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrhubarbandcustard.py
More file actions
38 lines (30 loc) · 1.01 KB
/
Copy pathrhubarbandcustard.py
File metadata and controls
38 lines (30 loc) · 1.01 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
from typing import Generator
from patterns.base import BasePattern
PINK = (255, 0, 255)
YELLOW = (255, 255, 0)
class RhubarbAndCustard(BasePattern):
fps: float = 6.0
_current_frame: int = 0
frames: list[list[tuple[int, int, int]]] = [
[PINK, PINK, YELLOW, YELLOW] * 6,
[YELLOW, PINK, PINK, YELLOW] * 6,
[YELLOW, YELLOW, PINK, PINK] * 6,
[PINK, YELLOW, YELLOW, PINK] * 6,
]
def __init__(self):
# super().__init__()
print(self.frames)
@property
def frame(self) -> list[tuple[int, int, int]]:
return self.frames[self._current_frame]
def next(self) -> list[tuple[int, int, int]]:
# _current_frame = self._current_frame + 1
self._current_frame = (self._current_frame + 1) % len(
self.frames
) # wrap around
return self.frame
def current(self):
return self.frame
def pattern(self) -> Generator[list[tuple[int, int, int]], None, None]:
while True:
yield self.next()