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.
8 9 10 11 12 13 14 15 16 |
# File 'lib/fantasy/color.rb', line 8 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.
32 33 34 |
# File 'lib/fantasy/color.rb', line 32 def palette @palette end |
Instance Attribute Details
#a ⇒ Object (readonly)
Returns the value of attribute a.
6 7 8 |
# File 'lib/fantasy/color.rb', line 6 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
6 7 8 |
# File 'lib/fantasy/color.rb', line 6 def b @b end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
6 7 8 |
# File 'lib/fantasy/color.rb', line 6 def g @g end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/fantasy/color.rb', line 6 def name @name end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
6 7 8 |
# File 'lib/fantasy/color.rb', line 6 def r @r end |
Instance Method Details
#hex ⇒ Object
18 19 20 21 22 |
# File 'lib/fantasy/color.rb', line 18 def hex [@r, @g, @b].map do |e| e.to_s(16).rjust(2, "0") end.join end |
#to_s ⇒ Object
24 25 26 27 28 29 |
# File 'lib/fantasy/color.rb', line 24 def to_s result = "r:#{@r}, g:#{@g}, b:#{@b}, a:#{@a}, hex:#{hex}" result += " (#{name})" unless name.nil? result end |