Class: Gdk::RGBA
- Inherits:
-
Object
- Object
- Gdk::RGBA
- Defined in:
- lib/gdk4/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.
52 53 54 55 56 57 58 |
# File 'lib/gdk4/rgba.rb', line 52 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/gdk4/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 |
.try_convert(value) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gdk4/rgba.rb', line 39 def try_convert(value) case value when String parse(value) when Symbol parse(value.to_s) else nil end end |
Instance Method Details
#initialize_raw ⇒ Object
51 |
# File 'lib/gdk4/rgba.rb', line 51 alias_method :initialize_raw, :initialize |
#to_a ⇒ Object
60 61 62 |
# File 'lib/gdk4/rgba.rb', line 60 def to_a [red, green, blue, alpha] end |