Class: SDL2::Color
Overview
SDL_pixels.h:252~258
Class Method Summary collapse
-
.cast(something) ⇒ Object
If possible, convert argument into a SDL::Color.
Instance Method Summary collapse
Methods inherited from Struct
Methods included from StructHelper
#member_readers, #member_writers
Constructor Details
This class inherits a constructor from SDL2::Struct
Class Method Details
.cast(something) ⇒ Object
If possible, convert argument into a SDL::Color
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sdl2/color.rb', line 16 def self.cast(something) if something.kind_of? Array something.map!(&:to_i) result = new result.set(*something) return result else return super end end |
Instance Method Details
#copy_from(color) ⇒ Object
35 36 37 38 39 |
# File 'lib/sdl2/color.rb', line 35 def copy_from(color) [:r, :g, :b, :a].each do |c| self.send("#{c}=", color.send(c)) end end |
#set(r, g, b, a = nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sdl2/color.rb', line 28 def set(r,g,b,a=nil) self.r = r self.g = g self.b = b self.a = a.nil? ? ALPHA_OPAQUE : a end |
#to_a ⇒ Object
41 42 43 |
# File 'lib/sdl2/color.rb', line 41 def to_a [r, g, b, a] end |