Skip to content

Commit 3d9487c

Browse files
committed
example. try to fix sphinx build error
1 parent a3d8c63 commit 3d9487c

File tree

5 files changed

+65
-1
lines changed

5 files changed

+65
-1
lines changed

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ Or the following command to update an existing version:
8989
Usage Example
9090
=============
9191

92+
.. code-block:: python
93+
94+
speech_blurb_bmp = OnDiskBitmap("example_image.bmp")
95+
speech_blurb = AnchoredTileGrid(bitmap=speech_blurb_bmp, pixel_shader=speech_blurb_bmp.pixel_shader)
96+
speech_blurb.anchor_point = (0.18, 1.0)
97+
speech_blurb.anchored_position = (60, 150)
9298
9399
Documentation
94100
=============

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7+
API Documentation
8+
=================
9+
710
.. automodule:: adafruit_anchored_tilegrid
811
:members:
Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim C for Adafruit Industries
22
#
3-
# SPDX-License-Identifier: Unlicense
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Illustrate usage of the AnchoredTileGrid class.
6+
7+
A speech blurb image is positioned relative to the
8+
point at the bottom of the blurb.
9+
"""
10+
11+
import board
12+
from displayio import Group, OnDiskBitmap, Palette
13+
from vectorio import Circle
14+
15+
from adafruit_anchored_tilegrid import AnchoredTileGrid
16+
17+
# Reference to built-in display
18+
display = board.DISPLAY
19+
20+
# palette to use for drawing a circle
21+
circle_palette = Palette(1)
22+
circle_palette[0] = 0xFF00FF
23+
24+
# circle object, we'll place our speech blurb near this
25+
circle = Circle(pixel_shader=circle_palette, radius=20, x=40, y=160)
26+
27+
# initialize a Group and add the circle to it
28+
main_group = Group()
29+
main_group.append(circle)
30+
31+
# load the speech blurb bitmap
32+
speech_blurb_bmp = OnDiskBitmap("example_image.bmp")
33+
34+
# make the background chroma key color transparent
35+
speech_blurb_bmp.pixel_shader.make_transparent(0)
36+
37+
# initialize an AnchoredTileGrid for the blurb
38+
speech_blurb = AnchoredTileGrid(bitmap=speech_blurb_bmp, pixel_shader=speech_blurb_bmp.pixel_shader)
39+
40+
# set the anchor point to the bottom point of the speech blurb
41+
speech_blurb.anchor_point = (0.18, 1.0)
42+
43+
# position it near the circle
44+
speech_blurb.anchored_position = (60, 150)
45+
46+
# add it to the group
47+
main_group.append(speech_blurb)
48+
49+
# set our group to root_group, so it gets shown on the display
50+
display.root_group = main_group
51+
52+
53+
while True:
54+
# wait forever so our group stays visible
55+
pass

examples/example_image.bmp

1.68 KB
Binary file not shown.

examples/example_image.bmp.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim C for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT

0 commit comments

Comments
 (0)