Sha256: a26864bc6534d256511e39ff6cdccde3a4c37c420a75d0a6703bf877dad3744c

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

module DotGrid
  module Page
    class Page
      attr_accessor(
        :pdf,
        :dot_weight,
        :grid_color,
        :spacing
      )

      def initialize(params)
        @pdf = params[:pdf]
        @dot_weight = params[:dot_weight] || 1.5
        @grid_color = params[:grid_color] || "B3B3B3"
        @spacing = params[:spacing] ? params[:spacing].mm : 5.mm
      end

      def generate
        pdf.start_new_page
      end

      def page_width
        pdf.bounds.width
      end

      def page_height
        pdf.bounds.height
      end

      def draw_dot_grid(rows, columns, left_start, height_start)
        pdf.fill_color grid_color
        (1..rows).each do |row|
          (1..columns).each do |col|
            pdf.fill_circle [left_start + (col-1)*spacing, height_start - spacing - (row-1)*spacing], dot_weight
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dot_grid-0.0.4 lib/dot_grid/page/page.rb