Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created February 3, 2012 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruprict/1726883 to your computer and use it in GitHub Desktop.
Save ruprict/1726883 to your computer and use it in GitHub Desktop.
ROFLBALT Framebuffer
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