Sha256: 73aa823fed28ba22fae45b3990a5cc05af1083cc50b5eaef26094ff95ab4637e

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

module DotGrid
  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 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dot_grid-0.0.3 lib/dot_grid/page.rb
dot_grid-0.0.1 lib/dot_grid/page.rb