aboutsummaryrefslogtreecommitdiff
path: root/lib/vec3.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vec3.rb')
-rw-r--r--lib/vec3.rb7
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