Class: Framebuffer
- Inherits:
-
Object
- Object
- Framebuffer
- Defined in:
- lib/roflbalt.rb
Instance Method Summary collapse
- #get(x, y) ⇒ Object
-
#initialize(background) ⇒ Framebuffer
constructor
A new instance of Framebuffer.
- #set(x, y, pixel) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(background) ⇒ Framebuffer
Returns a new instance of Framebuffer.
144 145 146 147 |
# File 'lib/roflbalt.rb', line 144 def initialize background @pixels = Hash.new { |h, k| h[k] = {} } @background = background end |
Instance Method Details
#get(x, y) ⇒ Object
151 152 153 |
# File 'lib/roflbalt.rb', line 151 def get x, y @pixels[x][y] || @background.pixel(x, y) end |
#set(x, y, pixel) ⇒ Object
148 149 150 |
# File 'lib/roflbalt.rb', line 148 def set x, y, pixel @pixels[x][y] = pixel end |
#size ⇒ Object
154 155 156 |
# File 'lib/roflbalt.rb', line 154 def size @pixels.values.reduce(0) { |a, v| a + v.size } end |