Sha256: 30b7926b60804a53a4ad7640d01ce21f9cf8fd271c499e36208ad1f0da7a9bbe

Contents?: true

Size: 839 Bytes

Versions: 3

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module RubyJard
  ##
  # Draw rendered screen bitmap in current screen window onto the screen.
  # Fulfill missing window if needed
  class ScreenDrawer
    def initialize(output:, screen:, color_scheme:)
      @output = output
      @screen = screen
      @color_decorator = RubyJard::Decorators::ColorDecorator.new(color_scheme)
    end

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_jard-0.3.1 lib/ruby_jard/screen_drawer.rb
ruby_jard-0.3.0 lib/ruby_jard/screen_drawer.rb
ruby_jard-0.2.3 lib/ruby_jard/screen_drawer.rb