Module: Text2048::CursesView::Colorize

Includes:
Curses
Included in:
Text2048::CursesView, Tile
Defined in:
lib/text2048/curses_view/colorize.rb

Overview

Colorize characters.

Constant Summary collapse

COLORS =
{
  nil => COLOR_BLACK,
  0 => COLOR_WHITE,
  2 => COLOR_WHITE,
  4 => COLOR_GREEN,
  8 => COLOR_GREEN,
  16 => COLOR_CYAN,
  32 => COLOR_CYAN,
  64 => COLOR_BLUE,
  128 => COLOR_BLUE,
  256 => COLOR_YELLOW,
  512 => COLOR_YELLOW,
  1024 => COLOR_MAGENTA,
  2048 => COLOR_RED
}

Instance Method Summary collapse

Instance Method Details

#color(number) ⇒ Object



28
29
30
# File 'lib/text2048/curses_view/colorize.rb', line 28

def color(number)
  COLORS[number]
end

#colorize(color, &block) ⇒ Object



32
33
34
35
# File 'lib/text2048/curses_view/colorize.rb', line 32

def colorize(color, &block)
  maybe_init_colors
  attron color_pair(color), &block
end