Class: Gdk::RGBA
- Inherits:
-
Object
- Object
- Gdk::RGBA
- Defined in:
- lib/gdk3/rgba.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(red = nil, green = nil, blue = nil, alpha = nil) ⇒ RGBA
constructor
A new instance of RGBA.
- #initialize_raw ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(red = nil, green = nil, blue = nil, alpha = nil) ⇒ RGBA
Returns a new instance of RGBA.
41 42 43 44 45 46 47 |
# File 'lib/gdk3/rgba.rb', line 41 def initialize(red=nil, green=nil, blue=nil, alpha=nil) initialize_raw self.red = red if red self.green = green if green self.blue = blue if blue self.alpha = alpha || 1.0 end |
Class Method Details
.parse(spec) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gdk3/rgba.rb', line 20 def parse(spec) rgba = new unless rgba.parse(spec) available_formats = [ "COLOR_NAME", "\#RGB", "\#RRGGBB", "\#RRRGGGBBB", "\#RRRRGGGGBBBB", "rgb(R, G, B)", "rgba(R, G, B, A)", ] = "invalid RGBA format: #{spec.inspect} " << "(available formats: #{available_formats.join(', ')})" raise ArgumentError, end rgba end |
Instance Method Details
#initialize_raw ⇒ Object
40 |
# File 'lib/gdk3/rgba.rb', line 40 alias_method :initialize_raw, :initialize |
#to_a ⇒ Object
49 50 51 |
# File 'lib/gdk3/rgba.rb', line 49 def to_a [red, green, blue, alpha] end |