Sha256: c73a2cdef231a1d521c848a54c1fd643efb5c80fc53f7f9e1a79f3d8f9c652b2

Contents?: true

Size: 993 Bytes

Versions: 8

Compression:

Stored size: 993 Bytes

Contents

module WhirledPeas
  module Graphics
    # Abstract base Painter class. Given a canvas and start coordinates (left, top), a painter
    # is responsible for generating the "strokes" that display the element.
    class Painter
      attr_reader :name, :settings

      def initialize(name, settings)
        @settings = settings
        @name = name
      end

      # Paint the element onto the canvas by yielding strokes to the block. A stroke is composed
      # of a left, top, and chars. E.g.
      #
      #   yield 10, 3, 'Hello World!'
      #
      # paints the string "Hello World!" in the 10th column from the left, 3rd row down.
      def paint(canvas, left, top, &block)
      end

      # Return a dimension object that provider the `outer_width` and `outer_height` of the
      # element being painted.
      def dimensions
      end

      def inspect
        "#{self.class.name.split('::').last}(name=#{name.inspect})"
      end
    end
    private_constant :Painter
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
whirled_peas-0.13.0 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.12.0 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.11.1 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.11.0 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.10.0 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.9.1 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.9.0 lib/whirled_peas/graphics/painter.rb
whirled_peas-0.8.0 lib/whirled_peas/graphics/painter.rb