Class: SDL::Palette
- Inherits:
-
NiceFFI::Struct
- Object
- NiceFFI::Struct
- SDL::Palette
- Includes:
- Enumerable
- Defined in:
- lib/ruby-sdl-ffi/sdl/video.rb
Instance Method Summary collapse
-
#at(index) ⇒ Object
Returns the color at the given index in the palette, as an SDL::Color instance.
-
#each ⇒ Object
Yields an SDL::Color for each color in the palette.
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 |
#each ⇒ Object
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 |