|
| 1 | +import board |
| 2 | +import displayio |
| 3 | +from adafruit_display_shapes.rect import Rect |
| 4 | +from adafruit_display_shapes.circle import Circle |
| 5 | +from adafruit_display_shapes.roundrect import RoundRect |
| 6 | +from adafruit_display_shapes.triangle import Triangle |
| 7 | +from adafruit_display_shapes.line import Line |
| 8 | +from adafruit_display_shapes.polygon import Polygon |
| 9 | + |
| 10 | +# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.) |
| 11 | +# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.) |
| 12 | +# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus |
| 13 | +display = board.DISPLAY |
| 14 | + |
| 15 | +# Make the display context |
| 16 | +splash = displayio.Group(max_size=20) |
| 17 | +display.show(splash) |
| 18 | + |
| 19 | +# Make a background color fill |
| 20 | +color_bitmap = displayio.Bitmap(display.width, display.height, 1) |
| 21 | +color_palette = displayio.Palette(1) |
| 22 | +color_palette[0] = 0xFFFFFF |
| 23 | +bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette) |
| 24 | +splash.append(bg_sprite) |
| 25 | +########################################################################## |
| 26 | + |
| 27 | +splash.append(Line(5, 74, 10, 110, 0x000000)) |
| 28 | +splash.append(Line(15, 74, 20, 110, 0x000000)) |
| 29 | +splash.append(Line(25, 74, 30, 110, 0x000000)) |
| 30 | +splash.append(Line(35, 74, 40, 110, 0x000000)) |
| 31 | + |
| 32 | +# Draw star |
| 33 | +polygon = Polygon( |
| 34 | + [ |
| 35 | + (255, 40), |
| 36 | + (262, 62), |
| 37 | + (285, 62), |
| 38 | + (265, 76), |
| 39 | + (275, 100), |
| 40 | + (255, 84), |
| 41 | + (235, 100), |
| 42 | + (245, 76), |
| 43 | + (225, 62), |
| 44 | + (248, 62), |
| 45 | + ], |
| 46 | + outline=0x000000, |
| 47 | +) |
| 48 | +splash.append(polygon) |
| 49 | + |
| 50 | +triangle = Triangle(170, 20, 140, 90, 210, 100, fill=0x999999, outline=0x000000) |
| 51 | +splash.append(triangle) |
| 52 | + |
| 53 | +rect = Rect(80, 20, 41, 41, fill=0x999999, outline=0x666666) |
| 54 | +splash.append(rect) |
| 55 | + |
| 56 | +circle = Circle(100, 100, 20, fill=0xFFFFFF, outline=0x000000) |
| 57 | +splash.append(circle) |
| 58 | + |
| 59 | +rect2 = Rect(70, 85, 61, 30, outline=0x0, stroke=3) |
| 60 | +splash.append(rect2) |
| 61 | + |
| 62 | +roundrect = RoundRect(10, 10, 61, 51, 10, fill=0x666666, outline=0x000000, stroke=6) |
| 63 | +splash.append(roundrect) |
| 64 | + |
| 65 | +display.refresh() |
| 66 | +while True: |
| 67 | + pass |
0 commit comments