fix tests

This commit is contained in:
jbb01 2024-08-05 15:14:59 +02:00
parent ebbf711403
commit 27e3fc0990
2 changed files with 13 additions and 9 deletions

View File

@ -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.io.TempDir;
@ -17,18 +19,18 @@ class ImageTest {
void test(@TempDir Path dir) throws IOException {
var image = new Image(256, 256);
for (var y = 0; y < image.height(); y++) {
for (var x = 0; x < image.width(); x++) {
var r = (double) x / (image.width() - 1);
var g = (double) y / (image.height() - 1);
for (var y = 0; y < image.getHeight(); y++) {
for (var x = 0; x < image.getWidth(); x++) {
var r = (double) x / (image.getWidth() - 1);
var g = (double) y / (image.getHeight() - 1);
var b = 0;
image.set(x, y, r, g, b);
image.set(x, y, new Color(r, g, b));
}
}
System.out.println(dir);
ImageIO.write(image, dir.resolve("img.ppm"));
ImageFormat.PPM.write(image, dir.resolve("img.ppm"));
String expected;
String actual;

View File

@ -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.Ray;
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 static org.junit.jupiter.api.Assertions.*;
@ -13,7 +15,7 @@ class SphereTest {
void hit() {
var center = new Vec3(1, 2, 3);
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 direction = new Vec3(-1, -1, -1);