-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframebuf.py
More file actions
executable file
·41 lines (32 loc) · 874 Bytes
/
framebuf.py
File metadata and controls
executable file
·41 lines (32 loc) · 874 Bytes
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
#!/usr/bin/python2.7
import struct
XRES = 800
YRES = 480
class Counter:
"""Counts up to a maximum in a given amount of steps
"""
def __init__(self, max, steps):
"""Set the target value and the steps required to reach there
Arguments:
- `max` :
- `steps`:
"""
self._max = max
self._steps = steps
self._current = 0
def next(self):
"""Next number
"""
ret = float(self._current)/float(self._steps)*self._max
self._current += 1
self._current %= self._steps
return ret
if __name__ == "__main__":
of = file("fb.rgba","wb")
r = Counter(255, XRES)
g = Counter(255, YRES)
for y in range(YRES):
_g = g.next()
for x in range(XRES):
_r = r.next()
of.write(struct.pack("BBBB", _r, _g, 0, 0x80))