public
Created

ROFLBALT Framebuffer

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.