Sha256: ac9612cd70411fe25db645ef90771c700b57c3846a2e53dd8fc14853fc876823

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

class Wx::Colour
  # Redefine the initialize method so it raises an exception if an
  # invalid colour value is given. This might be an unknown colour
  # string (eg 'dark blue') or out-of-bounds integer values (<0 or >255)
  wx_init = self.instance_method(:initialize)
  define_method(:initialize) do | *args |
    begin
      wx_init.bind(self).call(*args)
    # Invalid integer values raise SWIG 'no matching func'
    rescue ArgumentError, TypeError
      Kernel.raise ArgumentError, "Invalid colour values #{args.inspect}"
    end
  end

  # Missing Standard colour
  Wx::MAGENTA = new(255, 0, 255)

  # Colours are equal to one another if they have the same red, green
  # and blue intensity, and the same alpha
  def ==(other)
    case other
    when Wx::Colour
      [  self.red,  self.green,  self.blue,  self.alpha ] == 
      [ other.red, other.green, other.blue, other.alpha ]
    else
      false
    end
  end

  # More informative output for inspect etc
  def to_s
    "#<Wx::Colour: (#{red}, #{green}, #{blue} *#{alpha})>"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.rc.2 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.rc.1 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.beta.14 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.beta.13 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.beta.11 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.beta.10 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.beta.9 lib/wx/core/colour.rb
wxruby3-0.9.0.pre.beta.8 lib/wx/core/colour.rb