Class: SDL2::Color
Overview
SDL_pixels.h:252~258
Class Method Summary collapse
-
.cast(something) ⇒ Object
If possible, convert argument into a SDL::Color.
- .create(values = {}) ⇒ Object
Instance Method Summary collapse
Methods inherited from Struct
#==, #free, #initialize, release, #to_s, #update_members
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
21 22 23 24 25 26 27 28 29 |
# File 'lib/sdl2/color.rb', line 21 def self.cast(something) if something.kind_of? Array result = new result.set(*(something.map(&:to_i))) return result else return super end end |
.create(values = {}) ⇒ Object
15 16 17 18 |
# File 'lib/sdl2/color.rb', line 15 def self.create(values = {}) values[:a] ||= ALPHA_OPAQUE super(values) end |
Instance Method Details
#copy_from(color) ⇒ Object
38 39 40 41 42 |
# File 'lib/sdl2/color.rb', line 38 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
31 32 33 34 35 36 |
# File 'lib/sdl2/color.rb', line 31 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
44 45 46 |
# File 'lib/sdl2/color.rb', line 44 def to_a [r, g, b, a] end |