-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathpi_logo.py
executable file
·37 lines (29 loc) · 1002 Bytes
/
pi_logo.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2014-2020 Richard Hull and contributors
# See LICENSE.rst for details.
# PYTHON_ARGCOMPLETE_OK
"""
Display the Raspberry Pi logo (loads image as .png).
"""
from pathlib import Path
from demo_opts import get_device
from PIL import Image
def main():
img_path = str(Path(__file__).resolve().parent.joinpath('images', 'pi_logo.png'))
logo = Image.open(img_path).convert("RGBA")
fff = Image.new(logo.mode, logo.size, (255,) * 4)
background = Image.new("RGBA", device.size, "white")
posn = ((device.width - logo.width) // 2, 0)
while True:
for angle in range(0, 360, 2):
rot = logo.rotate(angle, resample=Image.BILINEAR)
img = Image.composite(rot, fff, rot)
background.paste(img, posn)
device.display(background.convert(device.mode))
if __name__ == "__main__":
try:
device = get_device()
main()
except KeyboardInterrupt:
pass