-
Notifications
You must be signed in to change notification settings - Fork 41
/
primitives.py
44 lines (31 loc) · 1.15 KB
/
primitives.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
39
40
41
42
43
44
# primitives.py micro-gui demo of use of graphics primitives
# Released under the MIT License (MIT). See LICENSE.
# Copyright (c) 2021 Peter Hinch
# hardware_setup must be imported before other modules because of RAM use.
import hardware_setup # Create a display instance
from gui.core.ugui import Screen, Window, ssd, display
from gui.widgets import Label, CloseButton
from gui.core.writer import CWriter
# Font for CWriter
import gui.fonts.font10 as font
from gui.core.colors import *
class BaseScreen(Screen):
def __init__(self):
super().__init__()
wri = CWriter(ssd, font, GREEN, BLACK, verbose=False)
col = 2
row = 2
Label(wri, row, col, 'Primitives')
CloseButton(wri) # Quit the application
def after_open(self):
display.usegrey(False)
# Coordinates are x, y as per framebuf
# circle method is in Display class only
display.circle(70, 70, 30, RED)
# These methods exist in framebuf, so also in SSD and Display
ssd.hline(0, 127, 128, BLUE)
ssd.vline(127, 0, 128, BLUE)
def test():
print('Primitives demo.')
Screen.change(BaseScreen)
test()