Protected Void FillTriangleEx (Graphics G, INT X1, INT Y1, INT X2, INT Y2,
INT X3, INT Y3)
{
INT infinit = -1;
INT A12, K12, A23, K23, A31, K31, A, K Download Adobe Reader
INT X_2, Y_2, X_3, Y_3, Step, Flag = 0, Deltak, K_12;
// Get three line equations:
// y = (Y1 - Y2) / (x1 - x2) * (x - x1) Y1
// y = (Y1 - Y3) / (x1 - x3) * (x - x1) Y1;
// y = (Y3 - Y2) / (x3 - x2) * (x - x3) Y3;
//
// A12 = (Y1 - Y2) / (x1 - x2);
// k12 = Y1 - (Y1 - Y2) / (x1 - x2) * x1 = (x1 * Y2 - x2 * Y1) / (x1 - x2);
// y = a12 * x k12;
//
A12 = a23 = a31 = -1;
K12 = k23 = k31 = -1;
IF ((x1 - x2)! = 0)
{
A12 = (Y1 - Y2) * 1000 / (x1 - x2);
K12 = (x1 * Y2 - x2 * y1) * 1000 / (x1 - x2);
}
Else Return;
IF ((x2 - x3)! = 0)
{
A23 = (Y2 - Y3) * 1000 / (x2 - x3);
K23 = (x2 * Y3 - x3 * Y2) * 1000 / (x2 - x3);
}
Else Return;
IF ((x3 - x1)! = 0)
{
A31 = (Y3 - Y1) * 1000 / (x3 - x1);
K31 = (x3 * Y1 - x1 * Y3) * 1000 / (x3 - x1);
}
Else Return;
// Use (x1, y1) and (x2, y2) this line as the bottom side.
// Parallel to (X3, Y3) direction drawing;
// It can be drawn because of the values of the change K (1, 2).
/ / But here is to determine the intersection of this line and other sides. Painting the line according to these points.
// This can determine the step number STEP of K change when (X3, Y3) is known.