import java.awt.Color;

/**
 * A driver that can be used to test the fillTriangle()
 * method in the Rasterizer2D class
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class TriangleTests
{
    /**
     * The entry point of the application
     *
     * @param args   The command line arguments
     */
    public static void main(String[] args)
    {
       FrameBuffer      fb;       
       GraphicsWindow   window;
       Rasterizer2D     rasterizer;
       

       window = new GraphicsWindow();

       fb = window.getFrameBuffer();

       rasterizer = new Rasterizer2D(fb);
       rasterizer.clear(Color.WHITE);
       rasterizer.setFillTechnique(Rasterizer2D.POINTWISE);
       
       // Flat top
       {
       double[] p1 = {-200.0,-200.0};
       double[] p2 = {-150.0,-150.0};
       double[] p3 = {-225.0,-150.0};
       rasterizer.fillTriangle(Color.GREEN, p1, p2, p3);
       fb.show();
       }
  
     
       // Flat bottom
       {
       double[] p1 = {-100.0,-100.0};
       double[] p2 = {   0.0,-100.0};
       double[] p3 = {-175.0,- 50.0};
       rasterizer.fillTriangle(Color.RED, p1, p2, p3);
       fb.show();
       }
       

       // Tall and thin
       {
       double[] p1 = {  50.0,-240.0};
       double[] p2 = { 200.0, 200.0};
       double[] p3 = { 100.0,  50.0};
       rasterizer.fillTriangle(Color.BLUE, p1, p2, p3);
       fb.show();
       }
       
     
       // Short and fat
       {
       double[] p1 = {-100.0, 100.0};
       double[] p2 = {  10.0, 110.0};
       double[] p3 = {   0.0, 225.0};
       rasterizer.fillTriangle(Color.MAGENTA, p1, p2, p3);
       fb.show();
       }
       
       


       fb.show();
    }
}
