projet-rendu/TestRasterizer.java

47 lines
1.1 KiB
Java
Raw Normal View History

2022-04-12 10:08:58 +00:00
/**
* Test class for the Rasterizer class
2022-04-14 20:42:57 +00:00
*
2022-04-12 10:08:58 +00:00
* @author: cdehais
2022-04-14 20:42:57 +00:00
*/
2022-04-12 10:08:58 +00:00
public class TestRasterizer {
2022-04-14 20:42:57 +00:00
2022-04-12 10:08:58 +00:00
static class TestShader extends Shader {
2022-04-14 20:42:57 +00:00
public TestShader(GraphicsWrapper screen) {
super(screen);
2022-04-12 10:08:58 +00:00
}
2022-04-14 20:42:57 +00:00
public void shade(Fragment fragment) {
System.out.println(" fragment: (" + fragment.getX() + ", " + fragment.getY() + ")"
+ " - color = (" + fragment.getColor() + ")");
2022-04-12 10:08:58 +00:00
}
}
public static void test() throws Exception {
System.out.println("OFF\n# Test Start");
2022-04-14 20:42:57 +00:00
TestShader shader = new TestShader(new GraphicsWrapper(256, 256));
Rasterizer rasterizer = new Rasterizer(shader);
2022-04-12 10:08:58 +00:00
2022-04-14 20:42:57 +00:00
System.out.println("Rasterizing edge");
Fragment v1 = new Fragment(0, 20);
v1.setColor(0, 0, 0);
Fragment v2 = new Fragment(5, -35);
v2.setColor(50, 100, 0);
2022-04-12 10:08:58 +00:00
2022-04-14 20:42:57 +00:00
rasterizer.rasterizeEdge(v1, v2);
}
2022-04-12 10:08:58 +00:00
2022-04-14 20:42:57 +00:00
public static void main(String[] args) {
2022-04-12 10:08:58 +00:00
try {
2022-04-14 20:42:57 +00:00
test();
2022-04-12 10:08:58 +00:00
} catch (Exception e) {
2022-04-14 20:42:57 +00:00
System.out.println("EXCEPTION: " + e);
e.printStackTrace();
2022-04-12 10:08:58 +00:00
}
2022-04-14 20:42:57 +00:00
}
2022-04-12 10:08:58 +00:00
}