Created
February 3, 2012 01:12
-
-
Save ruprict/1726883 to your computer and use it in GitHub Desktop.
ROFLBALT Framebuffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Framebuffer | |
def initialize background | |
@pixels = Hash.new { |h, k| h[k] = {} } | |
@background = background | |
end | |
def set x, y, pixel | |
@pixels[x][y] = pixel | |
end | |
def get x, y | |
@pixels[x][y] || @background.pixel(x, y) | |
end | |
def size | |
@pixels.values.reduce(0) { |a, v| a + v.size } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment