Class: UnicodePlot::AsciiCanvas

Inherits:
LookupCanvas show all
Defined in:
src/lib/unicode_plot/canvas/ascii_canvas.rb

Constant Summary collapse

ASCII_SIGNS =
[
  [ 0b100_000_000, 0b000_100_000, 0b000_000_100 ].freeze,
  [ 0b010_000_000, 0b000_010_000, 0b000_000_010 ].freeze,
  [ 0b001_000_000, 0b000_001_000, 0b000_000_001 ].freeze
].freeze
ASCII_LOOKUP =
{
  0b101_000_000 => '"',
  0b111_111_111 => '@',
 #0b011_110_011 => '$',
  0b010_000_000 => '\'',
  0b010_100_010 => '(',
  0b010_001_010 => ')',
  0b000_010_000 => '*',
  0b010_111_010 => '+',
  0b000_010_010 => ',',
  0b000_100_100 => ',',
  0b000_001_001 => ',',
  0b000_111_000 => '-',
  0b000_000_010 => '.',
  0b000_000_100 => '.',
  0b000_000_001 => '.',
  0b001_010_100 => '/',
  0b010_100_000 => '/',
  0b001_010_110 => '/',
  0b011_010_010 => '/',
  0b001_010_010 => '/',
  0b110_010_111 => '1',
 #0b111_010_100 => '7',
  0b010_000_010 => ':',
  0b111_000_111 => '=',
 #0b010_111_101 => 'A',
 #0b011_100_011 => 'C',
 #0b110_101_110 => 'D',
 #0b111_110_100 => 'F',
 #0b011_101_011 => 'G',
 #0b101_111_101 => 'H',
  0b111_010_111 => 'I',
 #0b011_001_111 => 'J',
 #0b101_110_101 => 'K',
  0b100_100_111 => 'L',
 #0b111_111_101 => 'M',
 #0b101_101_101 => 'N',
 #0b111_101_111 => 'O',
 #0b111_111_100 => 'P',
  0b111_010_010 => 'T',
 #0b101_101_111 => 'U',
  0b101_101_010 => 'V',
 #0b101_111_111 => 'W',
  0b101_010_101 => 'X',
  0b101_010_010 => 'Y',
  0b110_100_110 => '[',
  0b010_001_000 => '\\',
  0b100_010_001 => '\\',
  0b110_010_010 => '\\',
  0b100_010_011 => '\\',
  0b100_010_010 => '\\',
  0b011_001_011 => ']',
  0b010_101_000 => '^',
  0b000_000_111 => '_',
  0b100_000_000 => '`',
 #0b000_111_111 => 'a',
 #0b100_111_111 => 'b',
 #0b001_111_111 => 'd',
 #0b001_111_010 => 'f',
 #0b100_111_101 => 'h',
 #0b100_101_101 => 'k',
  0b110_010_011 => 'l',
 #0b000_111_101 => 'n',
  0b000_111_100 => 'r',
 #0b000_101_111 => 'u',
  0b000_101_010 => 'v',
  0b011_110_011 => '{',
  0b010_010_010 => '|',
  0b100_100_100 => '|',
  0b001_001_001 => '|',
  0b110_011_110 => '}',
}.freeze
ASCII_DECODE =
[' ']
PIXEL_PER_CHAR =
3

Constants inherited from Canvas

Canvas::CANVAS_CLASS_MAP

Constants included from StyledPrinter

StyledPrinter::COLOR_DECODE, StyledPrinter::COLOR_ENCODE, StyledPrinter::DISABLE_TEXT_STYLE, StyledPrinter::TEXT_COLORS

Instance Attribute Summary

Attributes inherited from Canvas

#height, #origin_x, #origin_y, #pixel_height, #pixel_width, #plot_height, #plot_width, #width, #x_pixel_per_char, #y_pixel_per_char

Instance Method Summary collapse

Methods inherited from LookupCanvas

#pixel!, #print_row

Methods inherited from Canvas

#char_at, #color_at, create, #index_at, #line!, #lines!, #point!, #points!, #print, #show

Methods included from BorderPrinter

#print_border_bottom, #print_border_top

Methods included from StyledPrinter

#print_color, #print_styled

Constructor Details

#initialize(width, height, **kw) ⇒ AsciiCanvas

Returns a new instance of AsciiCanvas.



110
111
112
113
114
# File 'src/lib/unicode_plot/canvas/ascii_canvas.rb', line 110

def initialize(width, height, **kw)
  super(width, height,
        PIXEL_PER_CHAR, PIXEL_PER_CHAR,
        **kw)
end

Instance Method Details

#lookup_decode(code) ⇒ Object



120
121
122
# File 'src/lib/unicode_plot/canvas/ascii_canvas.rb', line 120

def lookup_decode(code)
  ASCII_DECODE[code]
end

#lookup_encode(x, y) ⇒ Object



116
117
118
# File 'src/lib/unicode_plot/canvas/ascii_canvas.rb', line 116

def lookup_encode(x, y)
  ASCII_SIGNS[x][y]
end