Skip to content

Commit

Permalink
Pixel has default fg/bg colours.
Browse files Browse the repository at this point in the history
  • Loading branch information
pda committed Jan 15, 2012
1 parent 5237919 commit 2756dcd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions asc.rb
Expand Up @@ -84,9 +84,15 @@ def on_exit
end
end

class Pixel < Struct.new(:char, :fg, :bg)
class Pixel
def initialize char = " ", fg = nil, bg = nil
@char = char
@fg, @bg = fg, bg
end
def fg; @fg || 255 end
def bg; @bg || 0 end
def to_s
"\033[48;5;#{bg}m\033[38;5;#{fg}m#{char}\033[0m"
"\033[48;5;%dm\033[38;5;%dm%s\033[0m" % [ bg, fg, @char ]
end
end

Expand Down

0 comments on commit 2756dcd

Please sign in to comment.