Sha256: 7205cd8630300c6688ddaf12429dd625fd110f43483a61687bce71c2f8bd90ca

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

module Prawn
  module Graph
    module Charts
      module Legacy

        class Grid

          attr_accessor :width, :height, :point, :spacing, :document

          def initialize(grid_x_start, grid_y_start, grid_width, grid_height, spacing, document, theme = Prawn::Graph::Theme::Default)
            @point = [grid_x_start, grid_y_start]
            @width = grid_width
            @height = grid_height
            @spacing = spacing
            @document = document
            @theme = Prawn::Graph::Theme::Default
          end

          def start_x; @point.first; end
          def start_y; @point.last; end

          # Draws the Grid on the specified Prawn::Document
          #
          def draw
            @document.stroke_color @theme.markers
            if @theme.stroke_grid_markers
              (@height / @spacing).times do |x|
                offset = @spacing * (x + 1)
                @document.move_to [@point.first, (@point.last + offset)]
                @document.line_width(0.5)
                @document.stroke_line_to([(@point.first + @width), (@point.last + offset)])
              end
            end
            @document.move_to @point
            @document.line_width(2)
            @document.stroke_line_to([@point.first, @point.last + @height])
            @document.move_to @point
            @document.line_width(2)
            @document.stroke_line_to([(@point.first + @width), @point.last])
            @document.move_to @point.first, (@point.last + height)
            @document.stroke_color '000000'
            @document.line_width(1)
            @document.move_to @point
          end

        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prawn-graph-1.0.0.pre1 lib/prawn/graph/charts/legacy/grid.rb