Class: EhbGameLib::Nes::Palette
- Inherits:
-
Object
- Object
- EhbGameLib::Nes::Palette
- Defined in:
- lib/ehb_game_lib/nes/palette.rb
Constant Summary collapse
- COLORS_COUNT =
16
Instance Method Summary collapse
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
-
#initialize(all_colors) ⇒ Palette
constructor
A new instance of Palette.
Constructor Details
#initialize(all_colors) ⇒ Palette
Returns a new instance of Palette.
8 9 10 |
# File 'lib/ehb_game_lib/nes/palette.rb', line 8 def initialize(all_colors) @colors = Array.new(COLORS_COUNT) { |i| ::EhbGameLib::Nes::Color.new(all_colors, i) } end |
Instance Method Details
#[](index) ⇒ Object
12 13 14 |
# File 'lib/ehb_game_lib/nes/palette.rb', line 12 def [](index) @colors[index % @colors.length] end |
#[]=(index, value) ⇒ Object
16 17 18 |
# File 'lib/ehb_game_lib/nes/palette.rb', line 16 def []=(index, value) @colors[index % @colors.length].color_index = value end |