Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created February 3, 2012 01:09
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/1726864 to your computer and use it in GitHub Desktop.
Save ruprict/1726864 to your computer and use it in GitHub Desktop.
ROFLBALT Pixel
class Pixel
def initialize char = " ", fg = nil, bg = nil
@char = char
@fg, @bg = fg, bg
end
attr_reader :char
def fg; @fg || 255 end
def bg; @bg || 0 end
def to_s
"\033[48;5;%dm\033[38;5;%dm%s" % [ bg, fg, @char ]
end
def color_equal? other
fg == other.fg && bg == other.bg
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment