First we define a few useful objects
public class Vertex2D {
public float x, y; // coordinate of vertex
public int argb; // color of vertex
public Vertex2D(float xval, float yval, int cval) {
x = xval;
y = yval;
argb = cval;
}
}
A Drawable interface
import Raster;
public abstract interface Drawable {
public abstract void Draw(Raster r);
}
I will use integer coefficients in the edge equations for speed.
This implementation uses 12 fractional bits, thus, its practical
use will be limited to screens with resolutions of 4096 by 4096 or less.