Class: RubyJard::ScreenDrawer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_jard/screen_drawer.rb

Overview

Draw rendered screen bitmap in current screen window onto the screen. Fulfill missing window if needed

Instance Method Summary collapse

Constructor Details

#initialize(output:, screen:, color_scheme:) ⇒ ScreenDrawer

Returns a new instance of ScreenDrawer.



8
9
10
11
12
# File 'lib/ruby_jard/screen_drawer.rb', line 8

def initialize(output:, screen:, color_scheme:)
  @output = output
  @screen = screen
  @color_decorator = RubyJard::Decorators::ColorDecorator.new(color_scheme)
end

Instance Method Details

#drawObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_jard/screen_drawer.rb', line 14

def draw
  @screen.window.each_with_index do |line, index|
    RubyJard::Console.move_to(@output, @screen.layout.x, @screen.layout.y + index)
    @output.print line
  end
  (@screen.window.length..@screen.layout.height - 1).each do |index|
    RubyJard::Console.move_to(@output, @screen.layout.x, @screen.layout.y + index)
    @output.print @color_decorator.decorate(:background, ' ' * @screen.layout.width)
  end
end