Failing on triangles with both short sides on the left
bamert opened this issue · comments
Hey Josh,
thanks a lot for the code, I'm using it to rasterize triangles in a Delaunay triangulation. I discovered an issue in the case of triangles with both short sides on the left; the spans in this case reach from x1 to x2, where x1 > x2 and so no pixels are drawn in:
Line 118 in 263d823
The failure cases are exemplified in the image below (black triangles: failure case, gray: successfully rasterized)
![example](https://user-images.githubusercontent.com/3902685/33374346-15981168-d506-11e7-97da-ec48acd4f190.png)
I've fixed it by simply swapping the range limits if x2>x1.
Hey there,
That's cool! Glad to hear you found it useful. It's been a while since I worked on this, but it looks like the Span
constructor ensures that X1
is less than X2
, so I think that case should already be handled in the original code (it probably does make more sense to do the swapping when drawing the span, though)