Class: Hornetseye::RGB
Overview
Representation for colour pixel
Instance Attribute Summary collapse
-
#b ⇒ Object
Access blue channel.
-
#g ⇒ Object
Access green channel.
-
#r ⇒ Object
Access red channel.
Instance Method Summary collapse
-
#+@ ⇒ RGB
This operation has no effect.
-
#==(other) ⇒ Boolean
Test on equality.
-
#initialize(r, g, b) ⇒ RGB
constructor
Constructor.
-
#inspect ⇒ String
Return string with information about this object.
-
#nonzero? ⇒ Boolean, GCCValue
Check whether value is not equal to zero.
-
#swap_rgb ⇒ RGB
Swap colour channels.
-
#to_s ⇒ String
Return string with information about this object.
-
#zero? ⇒ Boolean, GCCValue
Check whether value is equal to zero.
Constructor Details
#initialize(r, g, b) ⇒ RGB
Constructor
Create new RGB object.
103 104 105 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 103 def initialize( r, g, b ) @r, @g, @b = r, g, b end |
Instance Attribute Details
#b ⇒ Object
Access blue channel
94 95 96 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 94 def b @b end |
#g ⇒ Object
Access green channel
89 90 91 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 89 def g @g end |
#r ⇒ Object
Access red channel
84 85 86 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 84 def r @r end |
Instance Method Details
#+@ ⇒ RGB
This operation has no effect
150 151 152 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 150 def +@ self end |
#==(other) ⇒ Boolean
Test on equality
200 201 202 203 204 205 206 207 208 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 200 def ==(other) if other.is_a? RGB @r.eq( other.r ).and( @g.eq( other.g ) ).and( @b.eq( other.b ) ) elsif RGB.generic? other @r.eq(other).and( @g.eq(other) ).and( @b.eq(other) ) else false end end |
#inspect ⇒ String
Return string with information about this object
110 111 112 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 110 def inspect "RGB(#{@r.inspect},#{@g.inspect},#{@b.inspect})" end |
#nonzero? ⇒ Boolean, GCCValue
Check whether value is not equal to zero
183 184 185 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 183 def nonzero? @r.nonzero?.or( @g.nonzero? ).or( @b.nonzero? ) end |
#swap_rgb ⇒ RGB
Swap colour channels
190 191 192 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 190 def swap_rgb RGB.new @b, @g, @r end |
#to_s ⇒ String
Return string with information about this object
117 118 119 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 117 def to_s "RGB(#{@r.to_s},#{@g.to_s},#{@b.to_s})" end |
#zero? ⇒ Boolean, GCCValue
Check whether value is equal to zero
176 177 178 |
# File 'docs/multiarray/lib/multiarray/rgb.rb', line 176 def zero? @r.zero?.and( @g.zero? ).and( @b.zero? ) end |