public class FlatTri implements Drawable {
protected Vertex2D v[];
protected EdgeEqn edge[];
protected int color;
protected int area;
protected int xMin, xMax, yMin, yMax;
private static byte sort[][] = {{0, 1}, {1, 2}, {0, 2}, {2, 0}, {2, 1}, {1, 0}};
public FlatTri() { // for future extension
}
public FlatTri(Vertex2D v0, Vertex2D v1, Vertex2D v2) {
v = new Vertex2D[3];
v[0] = v0;
v[1] = v1;
v[2] = v2;
// ... Paint triangle the average of it's vertex colors ...
int a = ((v0.argb >> 24) & 255) + ((v1.argb >> 24) & 255) + ((v2.argb >> 24) & 255);
int r = ((v0.argb >> 16) & 255) + ((v1.argb >> 16) & 255) + ((v2.argb >> 16) & 255);
int g = ((v0.argb >> 8) & 255) + ((v1.argb >> 8) & 255) + ((v2.argb >> 8) & 255);
int b = (v0.argb & 255) + (v1.argb & 255) + (v2.argb & 255);
a = (a + a + 3) / 6;
r = (r + r + 3) / 6;
g = (g + g + 3) / 6;
b = (b + b + 3) / 6;
color = (a << 24) | (r << 16) | (g << 8) | b;
}
|