Class: UnicodePlot::DotCanvas

Inherits:
LookupCanvas show all
Defined in:
src/lib/unicode_plot/canvas/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 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) ⇒ DotCanvas

Returns a new instance of DotCanvas.



22
23
24
25
26
# File 'src/lib/unicode_plot/canvas/dot_canvas.rb', line 22

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



32
33
34
# File 'src/lib/unicode_plot/canvas/dot_canvas.rb', line 32

def lookup_decode(code)
  DOT_DECODE[code]
end

#lookup_encode(x, y) ⇒ Object



28
29
30
# File 'src/lib/unicode_plot/canvas/dot_canvas.rb', line 28

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