Implement Display events
This commit is contained in:
27
display.py
27
display.py
@@ -29,3 +29,30 @@ class DisplayLyrics(DisplayContent):
|
||||
multiline=True,
|
||||
batch=obj.audiencebatch))
|
||||
|
||||
class DisplayImage(DisplayContent):
|
||||
def __init__(self, image, background=None):
|
||||
self._image = image
|
||||
self._background = background
|
||||
|
||||
def create(self, obj, width, height, x, y):
|
||||
|
||||
super().create(obj, width, height, x, y)
|
||||
|
||||
scale = min(width / self._image.width, height / self._image.height)
|
||||
|
||||
if self._background is not None:
|
||||
print("Background is {}".format(self._background))
|
||||
rectangle = pyglet.shapes.Rectangle(x=x + width//2, y=y + height//2,
|
||||
width=width, height=height,
|
||||
color=self._background,
|
||||
batch=obj.audiencebatch)
|
||||
rectangle.anchor_x = width//2
|
||||
rectangle.anchor_y = height//2
|
||||
obj.audiencecontent.append(rectangle)
|
||||
|
||||
sprite = pyglet.sprite.Sprite(img=self._image,
|
||||
x=x + width//2, y=y + height//2,
|
||||
batch=obj.audiencebatch)
|
||||
sprite.scale = scale
|
||||
obj.audiencecontent.append(sprite)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user