Class: FX::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/libGUIb14.rb,
lib/libGUIb16.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#aObject

Returns the value of attribute a.



175
176
177
# File 'lib/libGUIb14.rb', line 175

def a
  @a
end

#bObject

Returns the value of attribute b.



175
176
177
# File 'lib/libGUIb14.rb', line 175

def b
  @b
end

#gObject

Returns the value of attribute g.



175
176
177
# File 'lib/libGUIb14.rb', line 175

def g
  @g
end

#rObject

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

#serializeObject



197
198
199
# File 'lib/libGUIb14.rb', line 197

def serialize
  Fox.fxencodeColorData(to_FXColor)
end

#to_FXColorObject



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_sObject



206
207
208
# File 'lib/libGUIb14.rb', line 206

def to_s
  (@a ? [@r, @g, @b, @a] : [@r, @g, @b]).join(",")
end