Class: R2D::Color
- Inherits:
-
Object
- Object
- R2D::Color
- Defined in:
- lib/r2d/color.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Instance Method Summary collapse
-
#initialize(c) ⇒ Color
constructor
A new instance of Color.
Constructor Details
#initialize(c) ⇒ Color
Returns a new instance of Color.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/r2d/color.rb', line 8 def initialize(c) case c when "red" @r, @g, @b, @a = 255, 0, 0, 255 when "green" @r, @g, @b, @a = 0, 255, 0, 255 when "blue" @r, @g, @b, @a = 0, 0, 255, 255 when "black" @r, @g, @b, @a = 0, 0, 0, 255 when "white" @r, @g, @b, @a = 255, 255, 255, 255 when "yellow" @r, @g, @b, @a = 255, 255, 0, 255 when "orange" @r, @g, @b, @a = 255, 150, 0, 255 when "purple" @r, @g, @b, @a = 150, 30, 150, 255 when "random" @r, @g, @b, @a = rand(0..255), rand(0..255), rand(0..255), 255 when Array @r, @g = to_val(c[0]), to_val(c[1]) @b, @a = to_val(c[2]), to_val(c[3]) else raise Error, "Color does not exist!" end @adapter = R2D::Adapters.get_color(r, g, b, a) end |
Instance Attribute Details
#a ⇒ Object (readonly)
Returns the value of attribute a.
6 7 8 |
# File 'lib/r2d/color.rb', line 6 def a @a end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
6 7 8 |
# File 'lib/r2d/color.rb', line 6 def adapter @adapter end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
6 7 8 |
# File 'lib/r2d/color.rb', line 6 def b @b end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
6 7 8 |
# File 'lib/r2d/color.rb', line 6 def g @g end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
6 7 8 |
# File 'lib/r2d/color.rb', line 6 def r @r end |