Class: BDF::Char

Inherits:
Object
  • Object
show all
Defined in:
lib/bdf/char.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Char

Returns a new instance of Char.



3
4
5
6
7
8
9
# File 'lib/bdf/char.rb', line 3

def initialize(opts = {})
  @encoding = opts[:encoding]
  @swidth   = opts[:swidth]
  @dwidth   = opts[:dwidth]
  @bbx      = opts[:bbx]
  @bitmap   = parse(opts[:bitmap])
end

Instance Method Details

#render(canvas, cursor) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bdf/char.rb', line 11

def render(canvas, cursor)
  @bitmap.each_with_index do |line, y|
    line.each_with_index do |val, x|
      if val == 1
        canvas.set(x+cursor[0]+@bbx[:off_x], y+cursor[1]+@bbx[:off_y])
      end
    end
  end

  [cursor[0]+@dwidth[:x], cursor[1]+@dwidth[:y]]
end