Sha256: 2bd99859db7b66cb165f7e6fafa40f637656b8bfd9116fc0e2f7af8365dfaa8f

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

require_relative 'canvas'
require_relative 'pixel_grid'

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

      def paint
        # 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)
        pixel_grid = PixelGrid.new(width, height)
        template.paint(Canvas.new(0, 0, width, height), 0, 0) do |left, top, fstring|
          pixel_grid.add_stroke(left, top, fstring)
        end
        pixel_grid.to_s
      end

      private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whirled_peas-0.12.0 lib/whirled_peas/graphics/renderer.rb