Class: Color
- Inherits:
-
Gosu::Color
- Object
- Gosu::Color
- Color
- Defined in:
- lib/fantasy/color.rb
Class Attribute Summary collapse
-
.palette ⇒ Object
readonly
Returns the value of attribute palette.
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Instance Method Summary collapse
- #hex ⇒ Object
-
#initialize(r:, g:, b:, a: 255, name: nil) ⇒ Color
constructor
A new instance of Color.
- #to_s ⇒ Object
Constructor Details
#initialize(r:, g:, b:, a: 255, name: nil) ⇒ Color
Returns a new instance of Color.
6 7 8 9 10 11 12 13 14 |
# File 'lib/fantasy/color.rb', line 6 def initialize(r:, g:, b:, a: 255, name: nil) super(a, r, g, b) @a = a @r = r @g = g @b = b @name = name end |
Class Attribute Details
.palette ⇒ Object (readonly)
Returns the value of attribute palette.
30 31 32 |
# File 'lib/fantasy/color.rb', line 30 def palette @palette end |
Instance Attribute Details
#a ⇒ Object (readonly)
Returns the value of attribute a.
4 5 6 |
# File 'lib/fantasy/color.rb', line 4 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
4 5 6 |
# File 'lib/fantasy/color.rb', line 4 def b @b end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
4 5 6 |
# File 'lib/fantasy/color.rb', line 4 def g @g end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/fantasy/color.rb', line 4 def name @name end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
4 5 6 |
# File 'lib/fantasy/color.rb', line 4 def r @r end |
Instance Method Details
#hex ⇒ Object
16 17 18 19 20 |
# File 'lib/fantasy/color.rb', line 16 def hex [@r, @g, @b].map do |e| e.to_s(16).rjust(2, "0") end.join end |
#to_s ⇒ Object
22 23 24 25 26 27 |
# File 'lib/fantasy/color.rb', line 22 def to_s result = "r:#{@r}, g:#{@g}, b:#{@b}, a:#{@a}, hex:#{hex}" result += " (#{name})" unless name.nil? result end |