alien.py

../_images/alien.png

Randomly draw a jpg using the fast method on the display.

The alien.jpg is from the Erik Flowers Weather Icons available from https://github.com/erikflowers/weather-icons and is licensed under SIL OFL 1.1

It was was converted from the wi-alien.svg icon using ImageMagick’s convert utility:

convert wi-alien.svg -type TrueColor alien.jpg

 1"""
 2alien.py
 3========
 4
 5    .. figure:: /_static/alien.png
 6      :align: center
 7
 8      Randomly draw a jpg using the fast method on the display.
 9
10    The alien.jpg is from the Erik Flowers Weather Icons available from
11    https://github.com/erikflowers/weather-icons and is licensed under
12    SIL OFL 1.1
13
14    It was was converted from the wi-alien.svg icon using
15    ImageMagick's convert utility:
16
17    convert wi-alien.svg -type TrueColor alien.jpg
18"""
19
20import gc
21import random
22import gc9a01
23import tft_config
24
25
26def main():
27    """
28    Decode and draw jpg on display
29    """
30    gc.enable()
31    gc.collect()
32
33    tft = tft_config.config(tft_config.TALL)
34
35    # enable display and clear screen
36    tft.init()
37
38    # cache width and height
39    width = tft.width()
40    height = tft.height()
41
42    # display jpg in random locations
43    while True:
44        tft.rotation(random.randint(0, 4))
45        tft.jpg(
46            "alien.jpg",
47            random.randint(0, width - 30),
48            random.randint(0, height - 30),
49            gc9a01.FAST,
50        )
51
52
53main()