Class: SDL::Palette

Inherits:
NiceFFI::Struct
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruby-sdl-ffi/sdl/video.rb

Instance Method Summary collapse

Instance Method Details

#at(index) ⇒ Object

Returns the color at the given index in the palette, as an SDL::Color instance.



68
69
70
71
72
73
# File 'lib/ruby-sdl-ffi/sdl/video.rb', line 68

def at( index )
  index = (0...ncolors).to_a.at(index)
  if index
    SDL::Color.new( self[:colors] + index * SDL::Color.size )
  end
end

#eachObject

Yields an SDL::Color for each color in the palette.



76
77
78
# File 'lib/ruby-sdl-ffi/sdl/video.rb', line 76

def each
  ncolors.times{ |i|  yield at(i)  }
end