ⓘ If you ever see an old demo where they draw filled triangles. If the demo is s...

@meluzzy@woof.tech

ⓘ If you ever see an old demo where they draw filled triangles. If the demo is slow and you can see they first fill the triangle from the center to the bottom of the triangle and then from the center to the top or the other way around, It's because they are likely using Bresenham’s line algo to draw horizontal lines to fill the triangle. They could be using the general approach, but people prefer Bresenham's because it gives precise integer coordinates and thus it prevents gaps from showing up if you make a polygon out of triangles.

This requites to divide the triangle horizontally into 2 triangles of which the top one has a horizontal lower edge and the bottom one has a horizontal upper edge. Depending on the implementation you can fill the top one or the bottom one first. Or even do one pixel of the top one and then one pixel of the bottom one so you can make it look like the fill spreads horizontally from the center. Or make it look like it spreads from the top and lower vertices of the triangle to the center.*

Or... you could just draw the upper one first from top to bottom and then the lower one also from top to bottom. But that's boring.

^ When I say center I mean the horizontal line that goes from the vertex that is vertically in between the top and lower vertex to the opposite edge of the triangle.