class Rubytracer::Colour
Attributes
b[R]
g[R]
r[R]
Public Class Methods
new(r,g,b)
click to toggle source
# File lib/rubytracer/colour.rb, line 5 def initialize(r,g,b) @r = r @g = g @b = b end
Public Instance Methods
*(other)
click to toggle source
# File lib/rubytracer/colour.rb, line 19 def * other case other when Colour Colour.new(@r * other.r, @g * other.g, @b * other.b) else Colour.new(@r * other, @g * other, @b * other) end end
**(power)
click to toggle source
# File lib/rubytracer/colour.rb, line 28 def ** power Colour.new(@r ** power, @g ** power, @b ** power) end
+(other)
click to toggle source
# File lib/rubytracer/colour.rb, line 15 def + other Colour.new(@r + other.r, @g + other.g, @b + other.b) end
+@()
click to toggle source
# File lib/rubytracer/colour.rb, line 36 def +@ self end
-(other)
click to toggle source
# File lib/rubytracer/colour.rb, line 11 def - other Colour.new(@r - other.r, @g - other.g, @b - other.b) end
-@()
click to toggle source
# File lib/rubytracer/colour.rb, line 40 def -@ Colour.new(-@r, -@g, -@b) end
/(scale)
click to toggle source
# File lib/rubytracer/colour.rb, line 32 def / scale self * (1.0/scale) end
to_int()
click to toggle source
# File lib/rubytracer/colour.rb, line 44 def to_int [[[0, @r * 256].max, 255].min, [[0, @g * 256].max, 255].min, [[0, @b * 256].max, 255].min] end