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, #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 30 31 |
# File 'lib/sdl2/color.rb', line 21 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 |
.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
40 41 42 43 44 |
# File 'lib/sdl2/color.rb', line 40 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
33 34 35 36 37 38 |
# File 'lib/sdl2/color.rb', line 33 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
46 47 48 |
# File 'lib/sdl2/color.rb', line 46 def to_a [r, g, b, a] end |