Create a gist now

Instantly share code, notes, and snippets.

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