Sha256: 1f0db63ffd0a4d97635689d4a7b56f3164cb6774e4b575014ab50fe5de63a8c2

Contents?: true

Size: 676 Bytes

Versions: 2

Compression:

Stored size: 676 Bytes

Contents

require_relative 'canvas'

module WhirledPeas
  module Graphics
    class Renderer
      def initialize(template, width, height)
        @template = template
        @width = width
        @height = height
      end

      def paint(&block)
        # Modify the template's settings so that it fills the entire screen
        template.settings.width = width
        template.settings.height = height
        template.settings.sizing = :border
        template.settings.set_margin(left: 0, top: 0, right: 0, bottom: 0)
        template.paint(Canvas.new(0, 0, width, height), 0, 0, &block)
      end

      private

      attr_reader :template, :width, :height
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whirled_peas-0.7.1 lib/whirled_peas/graphics/renderer.rb
whirled_peas-0.7.0 lib/whirled_peas/graphics/renderer.rb