-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera_test.go
39 lines (30 loc) · 859 Bytes
/
camera_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package raytracer_test
import (
"testing"
r "github.com/derek-schaefer/raytracer"
"github.com/stretchr/testify/assert"
)
func TestNewCamera(t *testing.T) {
t.Skip()
}
func TestCameraRender(t *testing.T) {
world := r.NewHittables()
material := r.NewMetal(r.MetalOptions{Albedo: r.NewColor(0.8, 0.6, 0.2), Fuzz: 0.0})
world.Add(r.NewSphere(r.SphereOptions{Center: r.NewPoint3(0, 0, -1), Radius: 0.5, Material: material}))
camera := r.NewCamera(
r.CameraOptions{
AspectRatio: 16.0 / 9.0,
FieldOfView: 20,
ImageWidth: 400,
LookAt: r.NewPoint3(0, 0, -1),
LookFrom: r.NewPoint3(-2, 2, 1),
MaxDepth: 2,
Samples: 2,
ViewUp: r.NewPoint3(0, 1, 0),
},
)
image := camera.Render(world)
assert.Equal(t, image.Width, 400)
assert.Equal(t, image.Height, 225)
assert.Equal(t, len(image.Pixels), 400*225)
}