Description
The fill_triangle method seems to be drawing triangles incorrectly around the middle vertex (in the vertical direction). This appears to be related to the method drawing a horizontal line with the same y co-ordinate twice at the level of the middle vertex. The behaviour happens because the final value of the loop variable y in the loop used to fill the top part of the triangle is repeated for the first line used to fill the bottom part of the triangle. The code from the two loops is below for reference.
The images below illustrate the issue around the middle vertex.
I have developed and tested a fix for this employed in the repository framebuf2 and will post it here as a pull request separately in the next day or two. While I realise that this library is due to be deprecated soon, I figure it may still be worthwhile to fix it.
for y in range(y0, last + 1):
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)
sa = dx12 * (y - y1)
sb = dx02 * (y - y0)
while y <= y2:
a = x1 + sa // dy12
b = x0 + sb // dy02
sa += dx12
sb += dx02
if a > b:
a, b = b, a
self.hline(a, y, b - a + 1, *args, **kwargs)
y += 1