diff options
author | Nat Lasseter <user@4574.co.uk> | 2024-06-24 16:50:36 +0100 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2024-06-24 16:50:36 +0100 |
commit | 2f025ebfc6c9e3146ef1c356f99045edc203c9ee (patch) | |
tree | db279ad3999be6a545d7ba80eef521df63592b66 /vec3.go | |
parent | 63cee9aa6eb62afb2e8e726d2de16b76935c5f4c (diff) |
Chapter 8
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); } |