Class: DotGrid::Pattern::Checkerboard
- Defined in:
- lib/dot_grid/pattern/checkerboard.rb
Instance Attribute Summary
Attributes inherited from Pattern
Instance Method Summary collapse
Methods inherited from Pattern
#columns, #draw_grid, #initialize, #post_initialize, #rows
Constructor Details
This class inherits a constructor from DotGrid::Pattern::Pattern
Instance Method Details
#draw ⇒ Object
9 10 11 12 13 14 |
# File 'lib/dot_grid/pattern/checkerboard.rb', line 9 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 |
#draw_square?(row, column) ⇒ Boolean
5 6 7 |
# File 'lib/dot_grid/pattern/checkerboard.rb', line 5 def draw_square?(row, column) (row % 2 == 0 && column % 2 == 0) || (row % 2 == 1 && column % 2 == 1) end |