class DotGrid::Page::Planner

Constants

FOOT_HEIGHT_RATIO
HEADER_GAP_WIDTH
HEADER_LEFT_START
SQUARE_GRID_WIDTH

Attributes

dot_weight[RW]
grid_color[RW]
planner_color_1[RW]
planner_color_2[RW]
spacing[RW]

Public Instance Methods

dot_grid_bounds() click to toggle source
# File lib/dot_grid/page/planner.rb, line 32
def dot_grid_bounds
  ::DotGrid::BoundingBox.new(upper_left: [header_right_start, grid_top], width: header_right_width, height: grid_height)
end
draw_header(header_start, header_width, header_height, header_color) click to toggle source
# File lib/dot_grid/page/planner.rb, line 97
def draw_header(header_start, header_width, header_height, header_color)
  pdf.fill_color header_color
  pdf.fill_rectangle [header_start, page_height], header_width, header_height
end
generate() click to toggle source
Calls superclass method DotGrid::Page::Page#generate
# File lib/dot_grid/page/planner.rb, line 84
def generate
  super

  # Header left
  draw_header(header_left_start, header_left_width, header_height, header_left_color)

  # Header right
  draw_header(header_right_start, header_right_width, header_height, header_right_color)

  # Footer
  draw_footer(planner_color_1, header_left_start, footer_height, page_width-header_left_start)
end
grid_height() click to toggle source
# File lib/dot_grid/page/planner.rb, line 44
def grid_height
  (grid_top - footer_height - spacing)
end
grid_top() click to toggle source
# File lib/dot_grid/page/planner.rb, line 40
def grid_top
  page_height - header_height - spacing
end
header_gap_start() click to toggle source
# File lib/dot_grid/page/planner.rb, line 60
def header_gap_start
  header_left_start + header_left_width
end
header_gap_width() click to toggle source
# File lib/dot_grid/page/planner.rb, line 64
def header_gap_width
  page_width * HEADER_GAP_WIDTH
end
header_height() click to toggle source
# File lib/dot_grid/page/planner.rb, line 36
def header_height
  HEADER_HEIGHT * page_height
end
header_left_color() click to toggle source
# File lib/dot_grid/page/planner.rb, line 48
def header_left_color
  planner_color_1
end
header_left_start() click to toggle source
# File lib/dot_grid/page/planner.rb, line 52
def header_left_start
  HEADER_LEFT_START * page_width
end
header_left_width() click to toggle source
# File lib/dot_grid/page/planner.rb, line 56
def header_left_width
  ((SQUARE_GRID_WIDTH * page_width) / spacing).floor * spacing
end
header_right_color() click to toggle source
# File lib/dot_grid/page/planner.rb, line 68
def header_right_color
  planner_color_2
end
header_right_start() click to toggle source
# File lib/dot_grid/page/planner.rb, line 72
def header_right_start
  header_gap_start + header_gap_width
end
header_right_width() click to toggle source
# File lib/dot_grid/page/planner.rb, line 76
def header_right_width
  page_width - header_right_start
end
page_height() click to toggle source
# File lib/dot_grid/page/planner.rb, line 111
def page_height
  pdf.bounds.height
end
page_width() click to toggle source
# File lib/dot_grid/page/planner.rb, line 107
def page_width
  pdf.bounds.width
end
post_initialize(params) click to toggle source
# File lib/dot_grid/page/planner.rb, line 18
def post_initialize(params)
  @planner_color_1 = params[:planner_color_1] || "CCCCCC"
  @planner_color_2 = params[:planner_color_2] || "0099ff"
  @dot_weight = params[:dot_weight] || 1.5
  @grid_color = params[:grid_color] || "B3B3B3"
  @spacing = params[:spacing] ? params[:spacing].mm : 5.mm
  add_pattern(::DotGrid::Pattern::SquareGrid.new(params.merge!(:bounds => square_grid_bounds, grid_color: @planner_color_1)))
  add_pattern(::DotGrid::Pattern::DotGrid.new(params.merge!(:bounds => dot_grid_bounds)))
end
square_grid_bounds() click to toggle source
# File lib/dot_grid/page/planner.rb, line 28
def square_grid_bounds
  ::DotGrid::BoundingBox.new(upper_left: [header_left_start, grid_top], width: header_left_width, height: grid_height)
end