Class: FX::Color
- Inherits:
-
Object
- Object
- FX::Color
- Defined in:
- lib/libGUIb14.rb,
lib/libGUIb16.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
-
#g ⇒ Object
Returns the value of attribute g.
-
#r ⇒ Object
Returns the value of attribute r.
Instance Method Summary collapse
- #deserialize(data) ⇒ Object
- #from_FXColor(c) ⇒ Object
- #from_name(name) ⇒ Object
- #from_s(s) ⇒ Object
-
#initialize(r = 0, g = 0, b = 0, a = nil) ⇒ Color
constructor
A new instance of Color.
- #serialize ⇒ Object
- #to_FXColor ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(r = 0, g = 0, b = 0, a = nil) ⇒ Color
Returns a new instance of Color.
176 177 178 |
# File 'lib/libGUIb14.rb', line 176 def initialize r = 0, g = 0, b = 0, a = nil @r, @g, @b, @a = r, g, b, a end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
175 176 177 |
# File 'lib/libGUIb14.rb', line 175 def a @a end |
#b ⇒ Object
Returns the value of attribute b.
175 176 177 |
# File 'lib/libGUIb14.rb', line 175 def b @b end |
#g ⇒ Object
Returns the value of attribute g.
175 176 177 |
# File 'lib/libGUIb14.rb', line 175 def g @g end |
#r ⇒ Object
Returns the value of attribute r.
175 176 177 |
# File 'lib/libGUIb14.rb', line 175 def r @r end |
Instance Method Details
#deserialize(data) ⇒ Object
201 202 203 204 |
# File 'lib/libGUIb14.rb', line 201 def deserialize(data) from_FXColor(Fox.fxdecodeColorData(data)) self end |
#from_FXColor(c) ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/libGUIb14.rb', line 184 def from_FXColor c @r = Fox::FXREDVAL(c) @g = Fox::FXGREENVAL(c) @b = Fox::FXBLUEVAL(c) @a = Fox::FXALPHAVAL(c) self end |
#from_name(name) ⇒ Object
192 193 194 195 |
# File 'lib/libGUIb14.rb', line 192 def from_name(name) from_FXColor(Fox.fxcolorfromname(name)) self end |
#from_s(s) ⇒ Object
210 211 212 213 214 |
# File 'lib/libGUIb14.rb', line 210 def from_s s s = "0, 0, 0, 0" if s.size < 5 @r, @g, @b, @a = s.split(",").collect { |c| c.to_i } self end |
#serialize ⇒ Object
197 198 199 |
# File 'lib/libGUIb14.rb', line 197 def serialize Fox.fxencodeColorData(to_FXColor) end |
#to_FXColor ⇒ Object
180 181 182 |
# File 'lib/libGUIb14.rb', line 180 def to_FXColor @a ? Fox::FXRGBA(@r, @g, @b, @a) : Fox::FXRGB(@r, @g, @b) end |
#to_s ⇒ Object
206 207 208 |
# File 'lib/libGUIb14.rb', line 206 def to_s (@a ? [@r, @g, @b, @a] : [@r, @g, @b]).join(",") end |