-
Notifications
You must be signed in to change notification settings - Fork 0
/
aquila.py
40 lines (31 loc) · 1.06 KB
/
aquila.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.
# PYTHON_ARGCOMPLETE_OK
"""
Displays an animated gif.
"""
import os.path
from demo_opts import get_device
from PIL import Image, ImageSequence
from luma.core.sprite_system import framerate_regulator
def main():
regulator = framerate_regulator(fps=10)
img_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'images', 'aquila_mono_fix.gif'))
banana = Image.open(img_path)
size = [min(*device.size)] * 2
posn = ((device.width - size[0]) // 2, device.height - size[1])
while True:
for frame in ImageSequence.Iterator(banana):
with regulator:
background = Image.new("RGB", device.size, "white")
background.paste(frame.resize(size, resample=Image.LANCZOS), posn)
device.display(background.convert(device.mode))
if __name__ == "__main__":
try:
device = get_device()
main()
except KeyboardInterrupt:
pass