Skip to content

Commit 2c55a81

Browse files
committed
Update for release.
1 parent c56200a commit 2c55a81

File tree

10 files changed

+107
-39
lines changed

10 files changed

+107
-39
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cache:
1515
# or remove the env block entirely and remove the condition in the
1616
# deploy block.
1717
env:
18-
- DEPLOY_PYPI="false"
18+
- DEPLOY_PYPI="true"
1919

2020
deploy:
2121
- provider: releases
@@ -31,7 +31,7 @@ deploy:
3131
- provider: pypi
3232
user: adafruit-travis
3333
password:
34-
secure: #-- PASTE ENCRYPTED PASSWORD HERE --#
34+
secure: mK1brDPZMNqHXM83DNW+FxcwiWIeJXg4xMVkSCPLxCgB6sSd9S7uVjsQvxSy6TRKnM6X0n4BZDwYlgGMW80EODaM0LNgg7lB/VGa/ZAAPezXzAnZ12sVwpFkhr8DxlOZzGtQ7vODPiassuGPUzjyUX+pqoX8CIqeW9gHXduJY7sPdakVOQ565oV0Bm6VrcuNpHVtIVhlza+QZ8t/K4crVf0pl/p40cidyA01BeL2OXhjVQEbObu61YRv3DTmBKZSR3XtXFbeDwhl75k83Y2jyh9qdZyClA6/RtWrc5LicXEqCjrZMMKCdyXxEQcMIsQuDK0I+uPUfu6qgnqmeH5B2zYA0QXXjLf4QEJMmscRoespLTHJ4xatg+15/DpJhy5SguPdm/YeU+Ij3IgAP/Mj6IEKSDI9I1evVn9fdfFIMvz9EPScZanCuMpQZxMYDSAShofWwYqbhkKVaEAX7XmEyBxfVtOlalMRo+hW5MnB9wnNI8Ylooznrin6JkiTx95TZ6+sxdwXlvZqPwZ/rNhbNn9xWx/Qj/7HnjIvgNPYUXMOMnWeOHQgNxXGvVbgl+XT/F394cTgTi1f74dp32+D0GE6JO6GUQOKDFRzJF/N8NQzvSGn4CUnWE0c7QALcsw5TlKZ+HWrNyiQ7nlBrq59hj4LxBthFHtsE62xdqII9d4=
3535
on:
3636
tags: true
3737
condition: $DEPLOY_PYPI = "true"

README.rst

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ This is easily achieved by downloading
2828

2929
Installing from PyPI
3030
--------------------
31-
.. note:: This library is not available on PyPI yet. Install documentation is included
32-
as a standard element. Stay tuned for PyPI availability!
33-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
34-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
3531
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
3632
PyPI <https://pypi.org/project/adafruit-circuitpython-display_shapes/>`_. To install for current user:
3733

@@ -57,7 +53,39 @@ To install in a virtual environment in your current project:
5753
Usage Example
5854
=============
5955

60-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
56+
..code-block:: python
57+
58+
import board
59+
import displayio
60+
from adafruit_display_shapes.rect import Rect
61+
from adafruit_display_shapes.circle import Circle
62+
from adafruit_display_shapes.roundrect import RoundRect
63+
64+
splash = displayio.Group(max_size=10)
65+
board.DISPLAY.show(splash)
66+
67+
color_bitmap = displayio.Bitmap(320, 240, 1)
68+
color_palette = displayio.Palette(1)
69+
color_palette[0] = 0xFFFFFF
70+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, position=(0, 0))
71+
print(bg_sprite.position)
72+
splash.append(bg_sprite)
73+
74+
rect = Rect(80, 20, 41, 41, fill=0x0)
75+
splash.append(rect)
76+
77+
circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF)
78+
splash.append(circle)
79+
80+
rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3)
81+
splash.append(rect2)
82+
83+
roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6)
84+
splash.append(roundrect)
85+
86+
while True:
87+
pass
88+
6189

6290
Contributing
6391
============

adafruit_display_shapes/circle.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@
4545

4646

4747
class Circle(RoundRect):
48-
"""A circle, centered around (x0, y0) with radius r. Fill can be a hex
49-
value for the color or None for transparent. Outline can be a hex value
50-
for the color or None for no outline."""
48+
"""A circle.
49+
50+
:param x0: The x-position of the center.
51+
:param y0: The y-position of the center..
52+
:param r: The radius of the circle.
53+
:param fill: The color to fill the rounded-corner rectangle. Can be a hex value for a color or
54+
``None`` for transparent.
55+
:param outline: The outline of the rounded-corner rectangle. Can be a hex value for a color or
56+
``None`` for no outline.
57+
58+
"""
5159
def __init__(self, x0, y0, r, *, fill=None, outline=None):
5260
super().__init__(x0-r, y0-r, 2*r+1, 2*r+1, r, fill=fill, outline=outline)

adafruit_display_shapes/rect.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,21 @@
4545

4646

4747
class Rect(displayio.TileGrid):
48-
"""A rectangle, top left corner is (x, y) and size of width, height.
49-
Stroke is used for the outline, and will not change outer bound size set
50-
by width and height. Fill can be a hex value for the color or None for
51-
transparent. Outline can be a hex value for the color or None for no
52-
outline."""
53-
def __init__(self, x, y, width, height, *, stroke=1, fill=None, outline=None):
48+
"""A rectangle.
49+
50+
:param x: The x-position of the top left corner.
51+
:param y: The y-position of the top left corner.
52+
:param width: The width of the rectangle.
53+
:param height: The height of the rectangle.
54+
:param fill: The color to fill the rectangle. Can be a hex value for a color or
55+
``None`` for transparent.
56+
:param outline: The outline of the rectangle. Can be a hex value for a color or
57+
``None`` for no outline.
58+
:param stroke: Used for the outline. Will not change the outer bound size set by ``width`` and
59+
``height``.
60+
61+
"""
62+
def __init__(self, x, y, width, height, *, fill=None, outline=None, stroke=1):
5463
self._bitmap = displayio.Bitmap(width, height, 2)
5564
self._palette = displayio.Palette(2)
5665

@@ -73,6 +82,8 @@ def __init__(self, x, y, width, height, *, stroke=1, fill=None, outline=None):
7382

7483
@property
7584
def fill(self):
85+
"""The fill of the rectangle. Can be a hex value for a color or ``None`` for
86+
transparent."""
7687
return self._palette[0]
7788

7889
@fill.setter
@@ -84,6 +95,8 @@ def fill(self, color):
8495

8596
@property
8697
def outline(self):
98+
"""The outline of the rectangle. Can be a hex value for a color or ``None``
99+
for no outline."""
87100
return self._palette[1]
88101

89102
@outline.setter
@@ -100,6 +113,7 @@ def x(self):
100113

101114
@x.setter
102115
def x(self, x):
116+
# pylint: disable=attribute-defined-outside-init
103117
self.position = (x, self.position[1])
104118

105119
@property
@@ -109,4 +123,5 @@ def y(self):
109123

110124
@y.setter
111125
def y(self, y):
126+
# pylint: disable=attribute-defined-outside-init
112127
self.position = (self.position[0], y)

adafruit_display_shapes/roundrect.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,30 @@
4545

4646

4747
class RoundRect(displayio.TileGrid):
48-
"""A round-corner rectangle, top left corner is (x, y) and size of width, height.
49-
r is the radius of the rounded corner. Stroke is used for the outline, and will
50-
not change outer bound size set by width and height. Fill can be a hex value
51-
for the color or None for transparent. Outline can be a hex value for the color
52-
or None for no outline."""
53-
def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1): # pylint: disable=too-many-arguments
48+
# pylint: disable=too-many-arguments
49+
"""A round-corner rectangle.
50+
51+
:param x: The x-position of the top left corner.
52+
:param y: The y-position of the top left corner.
53+
:param width: The width of the rounded-corner rectangle.
54+
:param height: The height of the rounded-corner rectangle.
55+
:param r: The radius of the rounded corner.
56+
:param fill: The color to fill the rounded-corner rectangle. Can be a hex value for a color or
57+
``None`` for transparent.
58+
:param outline: The outline of the rounded-corner rectangle. Can be a hex value for a color or
59+
``None`` for no outline.
60+
:param stroke: Used for the outline. Will not change the outer bound size set by ``width`` and
61+
``height``.
62+
63+
"""
64+
def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1):
5465
self._palette = displayio.Palette(3)
5566
self._palette.make_transparent(0)
5667
self._bitmap = displayio.Bitmap(width, height, 3)
5768

5869
if fill is not None:
5970
for i in range(0, width): # draw the center chunk
60-
for j in range(r, height-r): # draw the center chunk
71+
for j in range(r, height - r): # draw the center chunk
6172
self._bitmap[i, j] = 2
6273
self._helper(r, r, r, color=2, fill=True,
6374
x_offset=width-2*r-1, y_offset=height-2*r-1)
@@ -68,24 +79,22 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1)
6879
if outline is not None:
6980
self._palette[1] = outline
7081
# draw flat sides
71-
for w in range(r, width-r):
82+
for w in range(r, width - r):
7283
for line in range(stroke):
7384
self._bitmap[w, line] = 1
7485
self._bitmap[w, height-line-1] = 1
75-
for _h in range(r, height-r):
86+
for _h in range(r, height - r):
7687
for line in range(stroke):
7788
self._bitmap[line, _h] = 1
7889
self._bitmap[width-line-1, _h] = 1
7990
# draw round corners
8091
self._helper(r, r, r, color=1, stroke=stroke,
8192
x_offset=width-2*r-1, y_offset=height-2*r-1)
82-
8393
super().__init__(self._bitmap, pixel_shader=self._palette, position=(x, y))
8494

85-
8695
# pylint: disable=invalid-name, too-many-locals, too-many-branches
8796
def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
88-
stroke=1, cornerflags=0xF, fill=False):
97+
stroke=1, corner_flags=0xF, fill=False):
8998
f = 1 - r
9099
ddF_x = 1
91100
ddF_y = -2 * r
@@ -100,7 +109,7 @@ def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
100109
x += 1
101110
ddF_x += 2
102111
f += ddF_x
103-
if cornerflags & 0x8:
112+
if corner_flags & 0x8:
104113
if fill:
105114
for w in range(x0-y, x0+y+x_offset):
106115
self._bitmap[w, y0+x+y_offset] = color
@@ -110,7 +119,7 @@ def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
110119
for line in range(stroke):
111120
self._bitmap[x0-y+line, y0+x+y_offset] = color
112121
self._bitmap[x0-x, y0+y+y_offset-line] = color
113-
if cornerflags & 0x1:
122+
if corner_flags & 0x1:
114123
if fill:
115124
for w in range(x0-y, x0+y+x_offset):
116125
self._bitmap[w, y0-x] = color
@@ -120,18 +129,20 @@ def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
120129
for line in range(stroke):
121130
self._bitmap[x0-y+line, y0-x] = color
122131
self._bitmap[x0-x, y0-y+line] = color
123-
if cornerflags & 0x4:
132+
if corner_flags & 0x4:
124133
for line in range(stroke):
125134
self._bitmap[x0+x+x_offset, y0+y+y_offset-line] = color
126135
self._bitmap[x0+y+x_offset-line, y0+x+y_offset] = color
127-
if cornerflags & 0x2:
136+
if corner_flags & 0x2:
128137
for line in range(stroke):
129138
self._bitmap[x0+x+x_offset, y0-y+line] = color
130139
self._bitmap[x0+y+x_offset-line, y0-x] = color
131140
# pylint: enable=invalid-name, too-many-locals, too-many-branches
132141

133142
@property
134143
def fill(self):
144+
"""The fill of the rounded-corner rectangle. Can be a hex value for a color or ``None`` for
145+
transparent."""
135146
return self._palette[2]
136147

137148
@fill.setter
@@ -143,6 +154,8 @@ def fill(self, color):
143154

144155
@property
145156
def outline(self):
157+
"""The outline of the rounded-corner rectangle. Can be a hex value for a color or ``None``
158+
for no outline."""
146159
return self._palette[1]
147160

148161
@outline.setter
@@ -160,6 +173,7 @@ def x(self):
160173

161174
@x.setter
162175
def x(self, x):
176+
# pylint: disable=attribute-defined-outside-init
163177
self.position = (x, self.position[1])
164178

165179
@property
@@ -169,4 +183,5 @@ def y(self):
169183

170184
@y.setter
171185
def y(self, y):
186+
# pylint: disable=attribute-defined-outside-init
172187
self.position = (self.position[0], y)

docs/api.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
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-
.. automodule:: adafruit_display_shapes
7+
.. automodule:: adafruit_display_shapes.circle
88
:members:
9+
10+
.. automodule:: adafruit_display_shapes.rect
11+
:members:
12+
13+
.. automodule:: adafruit_display_shapes.roundrect
14+
:members:

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
23+
autodoc_mock_imports = ["displayio"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

docs/index.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
2826

2927
.. toctree::
3028
:caption: Related Products
3129

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
3430

3531
.. toctree::
3632
:caption: Other Links
File renamed without changes.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@
6060
# simple. Or you can use find_packages().
6161
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
6262
# CHANGE `py_modules=['...']` TO `packages=['...']`
63-
py_modules=['adafruit_display_shapes'],
63+
packages=['adafruit_display_shapes'],
6464
)

0 commit comments

Comments
 (0)