Skip to content

Commit

Permalink
example. try to fix sphinx build error
Browse files Browse the repository at this point in the history
  • Loading branch information
FoamyGuy committed Oct 14, 2024
1 parent a3d8c63 commit 3d9487c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ Or the following command to update an existing version:
Usage Example
=============

.. code-block:: python
speech_blurb_bmp = OnDiskBitmap("example_image.bmp")
speech_blurb = AnchoredTileGrid(bitmap=speech_blurb_bmp, pixel_shader=speech_blurb_bmp.pixel_shader)
speech_blurb.anchor_point = (0.18, 1.0)
speech_blurb.anchored_position = (60, 150)
Documentation
=============
Expand Down
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
.. use this format as the module name: "adafruit_foo.foo"
API Documentation
=================

.. automodule:: adafruit_anchored_tilegrid
:members:
54 changes: 53 additions & 1 deletion examples/anchored_tilegrid_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim C for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
# SPDX-License-Identifier: MIT
"""
Illustrate usage of the AnchoredTileGrid class.
A speech blurb image is positioned relative to the
point at the bottom of the blurb.
"""

import board
from displayio import Group, OnDiskBitmap, Palette
from vectorio import Circle

from adafruit_anchored_tilegrid import AnchoredTileGrid

# Reference to built-in display
display = board.DISPLAY

# palette to use for drawing a circle
circle_palette = Palette(1)
circle_palette[0] = 0xFF00FF

# circle object, we'll place our speech blurb near this
circle = Circle(pixel_shader=circle_palette, radius=20, x=40, y=160)

# initialize a Group and add the circle to it
main_group = Group()
main_group.append(circle)

# load the speech blurb bitmap
speech_blurb_bmp = OnDiskBitmap("example_image.bmp")

# make the background chroma key color transparent
speech_blurb_bmp.pixel_shader.make_transparent(0)

# initialize an AnchoredTileGrid for the blurb
speech_blurb = AnchoredTileGrid(bitmap=speech_blurb_bmp, pixel_shader=speech_blurb_bmp.pixel_shader)

# set the anchor point to the bottom point of the speech blurb
speech_blurb.anchor_point = (0.18, 1.0)

# position it near the circle
speech_blurb.anchored_position = (60, 150)

# add it to the group
main_group.append(speech_blurb)

# set our group to root_group, so it gets shown on the display
display.root_group = main_group


while True:
# wait forever so our group stays visible
pass
Binary file added examples/example_image.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/example_image.bmp.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim C for Adafruit Industries
#
# SPDX-License-Identifier: MIT

0 comments on commit 3d9487c

Please sign in to comment.