Skip to content

Commit afeb2a2

Browse files
committed
adding anchored position example
1 parent 4d53a37 commit afeb2a2

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
This examples shows the use of anchor_point and anchored_position.
3+
"""
4+
import board
5+
import terminalio
6+
from adafruit_display_text import label
7+
import displayio
8+
9+
DISPLAY_WIDTH = 320
10+
DISPLAY_HEIGHT = 240
11+
12+
text_group = displayio.Group(max_size=9)
13+
text = "Hello"
14+
text_area_top_left = label.Label(terminalio.FONT, text=text)
15+
text_area_top_left.anchor_point = (0.0, 0.0)
16+
text_area_top_left.anchored_position = (10, 10)
17+
18+
text_area_top_middle = label.Label(terminalio.FONT, text=text)
19+
text_area_top_middle.anchor_point = (0.5, 0.0)
20+
text_area_top_middle.anchored_position = (DISPLAY_WIDTH/2, 10)
21+
22+
text_area_top_right = label.Label(terminalio.FONT, text=text)
23+
text_area_top_right.anchor_point = (1.0, 0.0)
24+
text_area_top_right.anchored_position = (DISPLAY_WIDTH-10, 10)
25+
26+
text_area_middle_left = label.Label(terminalio.FONT, text=text)
27+
text_area_middle_left.anchor_point = (0.0, 0.5)
28+
text_area_middle_left.anchored_position = (10,DISPLAY_HEIGHT/2)
29+
30+
text_area_middle_middle = label.Label(terminalio.FONT, text=text)
31+
text_area_middle_middle.anchor_point = (0.5, 0.5)
32+
text_area_middle_middle.anchored_position = (DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2)
33+
34+
text_area_middle_right = label.Label(terminalio.FONT, text=text)
35+
text_area_middle_right.anchor_point = (1.0, 0.5)
36+
text_area_middle_right.anchored_position = (DISPLAY_WIDTH-10, DISPLAY_HEIGHT/2)
37+
38+
39+
text_area_bottom_left = label.Label(terminalio.FONT, text=text)
40+
text_area_bottom_left.anchor_point = (0.0, 1.0)
41+
text_area_bottom_left.anchored_position = (10, DISPLAY_HEIGHT)
42+
43+
text_area_bottom_middle = label.Label(terminalio.FONT, text=text)
44+
text_area_bottom_middle.anchor_point = (0.5, 1.0)
45+
text_area_bottom_middle.anchored_position = (DISPLAY_WIDTH/2, DISPLAY_HEIGHT)
46+
47+
text_area_bottom_right = label.Label(terminalio.FONT, text=text)
48+
text_area_bottom_right.anchor_point = (1.0, 1.0)
49+
text_area_bottom_right.anchored_position = (DISPLAY_WIDTH-10, DISPLAY_HEIGHT)
50+
51+
text_group.append(text_area_top_middle)
52+
text_group.append(text_area_top_left)
53+
text_group.append(text_area_top_right)
54+
text_group.append(text_area_middle_middle)
55+
text_group.append(text_area_middle_left)
56+
text_group.append(text_area_middle_right)
57+
text_group.append(text_area_bottom_middle)
58+
text_group.append(text_area_bottom_left)
59+
text_group.append(text_area_bottom_right)
60+
61+
print(text_area_top_right.anchored_position)
62+
print(text_area_top_right.anchor_point)
63+
64+
board.DISPLAY.show(text_group)
65+
66+
while True:
67+
pass

0 commit comments

Comments
 (0)