Class: Rnes::Image
- Inherits:
-
Object
- Object
- Rnes::Image
- Defined in:
- lib/rnes/image.rb
Instance Attribute Summary collapse
- #height ⇒ Integer readonly
- #width ⇒ Integer readonly
Instance Method Summary collapse
-
#initialize(height:, width:) ⇒ Image
constructor
A new instance of Image.
- #read(x:, y:) ⇒ Object
- #write(value:, x:, y:) ⇒ Object
Constructor Details
#initialize(height:, width:) ⇒ Image
Returns a new instance of Image.
11 12 13 14 15 16 17 |
# File 'lib/rnes/image.rb', line 11 def initialize(height:, width:) @bytes = Array.new(height * width) do [0, 0, 0] end @height = height @width = width end |
Instance Attribute Details
#height ⇒ Integer (readonly)
4 5 6 |
# File 'lib/rnes/image.rb', line 4 def height @height end |
#width ⇒ Integer (readonly)
7 8 9 |
# File 'lib/rnes/image.rb', line 7 def width @width end |
Instance Method Details
#read(x:, y:) ⇒ Object
21 22 23 |
# File 'lib/rnes/image.rb', line 21 def read(x:, y:) @bytes[@width * y + x] end |
#write(value:, x:, y:) ⇒ Object
28 29 30 |
# File 'lib/rnes/image.rb', line 28 def write(value:, x:, y:) @bytes[@width * y + x] = value end |