Skip to content

Commit a1a80d8

Browse files
authored
Use color index constants in triangle
1 parent 3be187b commit a1a80d8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

adafruit_display_shapes/triangle.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(
101101
point_a[1] - y0,
102102
point_b[0] - min(xs),
103103
point_b[1] - y0,
104-
1,
104+
self._OUTLINE,
105105
)
106106

107107
# pylint: disable=invalid-name, too-many-branches
@@ -126,7 +126,7 @@ def _draw_filled(
126126
a = x2
127127
elif x2 > b:
128128
b = x2
129-
self._line(a, y0, b, y0, 2)
129+
self._line(a, y0, b, y0, self._FILL)
130130
return
131131

132132
if y1 == y2:
@@ -140,29 +140,29 @@ def _draw_filled(
140140
b = round(x0 + (x2 - x0) * (y - y0) / (y2 - y0))
141141
if a > b:
142142
a, b = b, a
143-
self._line(a, y, b, y, 2)
143+
self._line(a, y, b, y, self._FILL)
144144
# Lower Triangle
145145
for y in range(last + 1, y2 + 1):
146146
a = round(x1 + (x2 - x1) * (y - y1) / (y2 - y1))
147147
b = round(x0 + (x2 - x0) * (y - y0) / (y2 - y0))
148148

149149
if a > b:
150150
a, b = b, a
151-
self._line(a, y, b, y, 2)
151+
self._line(a, y, b, y, self._FILL)
152152

153153
# pylint: enable=invalid-name, too-many-locals, too-many-branches
154154

155155
@property
156156
def fill(self) -> Optional[int]:
157157
"""The fill of the triangle. Can be a hex value for a color or
158158
``None`` for transparent."""
159-
return self._palette[2]
159+
return self._palette[self._FILL]
160160

161161
@fill.setter
162162
def fill(self, color: Optional[int]) -> None:
163163
if color is None:
164-
self._palette[2] = 0
165-
self._palette.make_transparent(2)
164+
self._palette[self._FILL] = 0
165+
self._palette.make_transparent(self._FILL)
166166
else:
167-
self._palette[2] = color
168-
self._palette.make_opaque(2)
167+
self._palette[self._FILL] = color
168+
self._palette.make_opaque(self._FILL)

0 commit comments

Comments
 (0)