diff options
Diffstat (limited to 'vec3.go')
-rw-r--r-- | vec3.go | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -53,9 +53,11 @@ func (v Vec3) Cross(w Vec3) Vec3 { } func (v Vec3) ToPPM() string { - r := uint8(255.999 * v.X); - g := uint8(255.999 * v.Y); - b := uint8(255.999 * v.Z); + i := Interval{0, 0.999}; + + r := uint8(256 * i.Clamp(v.X)); + g := uint8(256 * i.Clamp(v.Y)); + b := uint8(256 * i.Clamp(v.Z)); return fmt.Sprintf("%3d %3d %3d", r, g, b); } |