|
@@ -43,9 +43,35 @@ static void drawFillBottomFlatTriangle(int32_t x0, int32_t y0, int32_t x1, int32
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/* This function expect Point 2 to be the bottom, 0 to be the top left, 1 to be the top right */
|
|
|
static void drawFillTopFlatTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t colour)
|
|
|
{
|
|
|
+ int i;
|
|
|
+ int32_t deltaXL = x0 - x2;
|
|
|
+ int32_t deltaXR = x1 - x2;
|
|
|
+ int32_t deltaY = y0 - y2;
|
|
|
+ int32_t sideLength = abs(deltaY);
|
|
|
+
|
|
|
+ if (sideLength == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double incrementXL = deltaXL / (double)sideLength;
|
|
|
+ double incrementXR = deltaXR / (double)sideLength;
|
|
|
+ double incrementY = deltaY / (double)sideLength;
|
|
|
+
|
|
|
+ double currentXL = x2;
|
|
|
+ double currentXR = x2;
|
|
|
+ double currentY = y2;
|
|
|
|
|
|
+ for(i = 0; i <= sideLength; i++)
|
|
|
+ {
|
|
|
+ drawHLine(round(currentXL), round(currentY), round(currentXR), colour);
|
|
|
+ currentXL += incrementXL;
|
|
|
+ currentXR += incrementXR;
|
|
|
+ currentY += incrementY;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void drawFilledTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t colour)
|