diff options
author | Nat Lasseter <user@4574.co.uk> | 2024-06-12 21:26:19 +0100 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2024-06-12 21:26:19 +0100 |
commit | 51416f5dfac39b6ede8340b57b9bed4eb3edc646 (patch) | |
tree | fa840f778dd5a48bc915dd43609d5065b5e1d115 /lib/vec3.rb | |
parent | df7c4a808d691e1d927047bb86aa9738780e694d (diff) |
Done Chapter 8
Diffstat (limited to 'lib/vec3.rb')
-rw-r--r-- | lib/vec3.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/vec3.rb b/lib/vec3.rb index 6287813..b9a5a73 100644 --- a/lib/vec3.rb +++ b/lib/vec3.rb @@ -69,6 +69,11 @@ class Colour < Vec3 def b; @z; end def to_ppm - "%3d %3d %3d" % [(r * 255.999).to_i, (g * 255.999).to_i, (b * 255.999).to_i] + intensity = Interval.new(0.0, 0.999) + "%3d %3d %3d" % [ + (intensity.clamp(r) * 256).to_i, + (intensity.clamp(g) * 256).to_i, + (intensity.clamp(b) * 256).to_i + ] end end |