Class: UnicodePlot::DotCanvas

Inherits:
LookupCanvas show all
Defined in:
lib/unicode_plot/dot_canvas.rb

Constant Summary collapse

DOT_SIGNS =
[
  [
    0b10,
    0b01
  ].freeze
].freeze
DOT_DECODE =
[
  -' ', # 0b00
  -'.', # 0b01
  -"'", # 0b10
  -':', # 0b11
].freeze
X_PIXEL_PER_CHAR =
1
Y_PIXEL_PER_CHAR =
2

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

#color?, #print_color, #print_styled

Constructor Details

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

Returns a new instance of DotCanvas.



20
21
22
23
24
# File 'lib/unicode_plot/dot_canvas.rb', line 20

def initialize(width, height, **kw)
  super(width, height,
        X_PIXEL_PER_CHAR, Y_PIXEL_PER_CHAR,
        **kw)
end

Instance Method Details

#lookup_decode(code) ⇒ Object



30
31
32
# File 'lib/unicode_plot/dot_canvas.rb', line 30

def lookup_decode(code)
  DOT_DECODE[code]
end

#lookup_encode(x, y) ⇒ Object



26
27
28
# File 'lib/unicode_plot/dot_canvas.rb', line 26

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