fix tests
This commit is contained in:
parent
ebbf711403
commit
27e3fc0990
@ -1,5 +1,7 @@
|
|||||||
package eu.jonahbauer.raytracing.render;
|
package eu.jonahbauer.raytracing.render.canvas;
|
||||||
|
|
||||||
|
import eu.jonahbauer.raytracing.render.Color;
|
||||||
|
import eu.jonahbauer.raytracing.render.ImageFormat;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
@ -17,18 +19,18 @@ class ImageTest {
|
|||||||
void test(@TempDir Path dir) throws IOException {
|
void test(@TempDir Path dir) throws IOException {
|
||||||
var image = new Image(256, 256);
|
var image = new Image(256, 256);
|
||||||
|
|
||||||
for (var y = 0; y < image.height(); y++) {
|
for (var y = 0; y < image.getHeight(); y++) {
|
||||||
for (var x = 0; x < image.width(); x++) {
|
for (var x = 0; x < image.getWidth(); x++) {
|
||||||
var r = (double) x / (image.width() - 1);
|
var r = (double) x / (image.getWidth() - 1);
|
||||||
var g = (double) y / (image.height() - 1);
|
var g = (double) y / (image.getHeight() - 1);
|
||||||
var b = 0;
|
var b = 0;
|
||||||
|
|
||||||
image.set(x, y, r, g, b);
|
image.set(x, y, new Color(r, g, b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(dir);
|
System.out.println(dir);
|
||||||
ImageIO.write(image, dir.resolve("img.ppm"));
|
ImageFormat.PPM.write(image, dir.resolve("img.ppm"));
|
||||||
|
|
||||||
String expected;
|
String expected;
|
||||||
String actual;
|
String actual;
|
@ -1,8 +1,10 @@
|
|||||||
package eu.jonahbauer.raytracing.scene;
|
package eu.jonahbauer.raytracing.scene.hittable3d;
|
||||||
|
|
||||||
import eu.jonahbauer.raytracing.math.Range;
|
import eu.jonahbauer.raytracing.math.Range;
|
||||||
import eu.jonahbauer.raytracing.math.Ray;
|
import eu.jonahbauer.raytracing.math.Ray;
|
||||||
import eu.jonahbauer.raytracing.math.Vec3;
|
import eu.jonahbauer.raytracing.math.Vec3;
|
||||||
|
import eu.jonahbauer.raytracing.render.Color;
|
||||||
|
import eu.jonahbauer.raytracing.render.material.LambertianMaterial;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -13,7 +15,7 @@ class SphereTest {
|
|||||||
void hit() {
|
void hit() {
|
||||||
var center = new Vec3(1, 2, 3);
|
var center = new Vec3(1, 2, 3);
|
||||||
var radius = 5;
|
var radius = 5;
|
||||||
var sphere = new Sphere(center, radius);
|
var sphere = new Sphere(center, radius, new LambertianMaterial(Color.WHITE));
|
||||||
|
|
||||||
var origin = new Vec3(6, 7, 8);
|
var origin = new Vec3(6, 7, 8);
|
||||||
var direction = new Vec3(-1, -1, -1);
|
var direction = new Vec3(-1, -1, -1);
|
Loading…
x
Reference in New Issue
Block a user