Sha256: f506257c97587f0b83c025a133050e1c4b9d9604750b315e164ba5a1cbd68fb7

Contents?: true

Size: 422 Bytes

Versions: 8

Compression:

Stored size: 422 Bytes

Contents

module DotGrid
  module Pattern
    class Checkerboard < Pattern

      def draw_square?(row, column)
        (row % 2 == 0 && column % 2 == 0) || (row % 2 == 1 && column % 2 == 1)
      end

      def draw
        pdf.fill_color grid_color
        draw_grid do |row, column|
          pdf.fill_rectangle [column*spacing, row*spacing], spacing, spacing if draw_square?(row, column)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dot_grid-0.0.12 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.11 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.10 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.9 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.8 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.7 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.6 lib/dot_grid/pattern/checkerboard.rb
dot_grid-0.0.5 lib/dot_grid/pattern/checkerboard.rb