Skip to content

Commit

Permalink
Merge pull request #34 from peter-l5/main
Browse files Browse the repository at this point in the history
fix fill_triangle bug issue #33
  • Loading branch information
dhalbert committed May 11, 2023
2 parents 6e6bdd0 + 599db1b commit 445b09f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions adafruit_gfx/gfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ def fill_triangle(self, x0, y0, x1, y1, x2, y2, *args, **kwargs):
x0, x1 = x1, x0
a = 0
b = 0
y = 0
last = 0
if y0 == y2:
a = x0
Expand Down Expand Up @@ -278,18 +277,20 @@ def fill_triangle(self, x0, y0, x1, y1, x2, y2, *args, **kwargs):
dy12 = 1
sa = 0
sb = 0
if y1 == y2 or y0 == y1: # pylint: disable=consider-using-in
last = y1
else:
y = y0
if y0 == y1:
last = y1 - 1
for y in range(y0, last + 1):
else:
last = y1
while y <= last:
a = x0 + sa // dy01
b = x0 + sb // dy02
sa += dx01
sb += dx02
if a > b:
a, b = b, a
self.hline(a, y, b - a + 1, *args, **kwargs)
y += 1
sa = dx12 * (y - y1)
sb = dx02 * (y - y0)
while y <= y2:
Expand Down

0 comments on commit 445b09f

Please sign in to comment.