Merge branch 'master' of github.com:JanKlopper/pixelvloed
Conflicts: vloed.py
This commit is contained in:
commit
562ae26d7f
2 changed files with 28 additions and 25 deletions
|
|
@ -17,7 +17,6 @@ import random
|
|||
import time
|
||||
|
||||
class MaxSizeList(list):
|
||||
maxsize = 0
|
||||
|
||||
def __init__(self, maxcount=100):
|
||||
self.maxsize = maxcount
|
||||
|
|
@ -28,7 +27,6 @@ class MaxSizeList(list):
|
|||
if self.__len__() == self.maxsize:
|
||||
raise IndexError('max size reached')
|
||||
|
||||
|
||||
def RGBPixel(x, y, r, g, b, a=None): # pylint: disable=C0103
|
||||
"""Generates the packed data for a pixel"""
|
||||
if a:
|
||||
|
|
@ -58,7 +56,7 @@ def RandomFill(width=640, height=480):
|
|||
message.append(pixel)
|
||||
except IndexError:
|
||||
yield ''.join(message)
|
||||
message[:] = []
|
||||
message[2:] = []
|
||||
message.append(pixel)
|
||||
yield ''.join(message)
|
||||
|
||||
|
|
|
|||
5
vloed.py
5
vloed.py
|
|
@ -103,6 +103,7 @@ class Canvas(object):
|
|||
# while we have stuff in the queue, and its not our next time to draw a
|
||||
# frame, lets process packets from the queue
|
||||
while time.time() < returntime and not self.queue.empty():
|
||||
try:
|
||||
data = self.queue.get()
|
||||
preamble = struct.unpack_from("<?", data)[0]
|
||||
protocol = struct.unpack_from("<B", data, 1)[0]
|
||||
|
|
@ -123,6 +124,10 @@ class Canvas(object):
|
|||
if self.debug:
|
||||
print pixel
|
||||
self.Pixel(*pixel)
|
||||
except Exception as e:
|
||||
if self.debug:
|
||||
# All exceptions will be printed, but won't result in a crash.
|
||||
print e
|
||||
# indicate that we have been drawing stuff
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue