   header_height = 40
   cols = fret_count + 1
   rows = (string_count - hidden_strings.length)
-  canvas_width = fretboard_width_with_gutter * cols + canvas_gutter * cols
-  canvas_height = header_height + fretboard_height_with_gutter * rows + canvas_gutter * rows
+  canvas_width = padded_fretboard_width * cols + canvas_gutter * cols
+  canvas_height = header_height + padded_fretboard_height * rows + canvas_gutter * rows
 
   canvas = new Canvas(canvas_width, canvas_height, pdf and 'pdf') unless pdf and canvas
   ctx = canvas.getContext('2d')


# intervals_from_root_book()

chord_page = (title, intervals, outervals, pdf) ->
  outervals ||= []

  canvas_gutter = 20
  header_height = 40
  diagram_title_height = 30
  cols = 3
  rows = 4
  if draw_diagrams
    diagram_title_height = 15
    canvas_gutter = 2
  canvas_width = fretboard_width_with_gutter * cols + canvas_gutter * cols
  canvas_height = header_height + (fretboard_height_with_gutter + diagram_title_height) * rows + canvas_gutter * rows

  roots = []
  positions_each (string, fret) ->
    number = note_number_at(string, fret) % 12
    roots[number] = [string, fret]

  canvas = new Canvas(canvas_width, canvas_height, pdf and 'pdf') unless pdf and canvas
  ctx = canvas.getContext('2d')
  ctx.textDrawingMode = 'glyph' if pdf
  erase_background()

  ctx.font = '20px Impact'
  ctx.fillStyle = 'rgb(128, 128, 128)'
  ctx.fillText "#{title} Chords", canvas_gutter / 2, header_height

  note_names = "E F F# G G# A A# B C C# D D#".split(/\s/)
  colors = ['red', 'blue', 'green', 'orange']
  other_colors = ['rgba(255,0,0 ,.1)', 'rgba(0,0,255, 0.1)', 'rgba(0,255,0, 0.1)', 'rgba(255,0,255, 0.1)']

  roots.map (note, ix) ->
    note_number = (ix * 5 + 7) % 12
    note = roots[note_number]
    string = note[0]
    fret = note[1]
    col = ix % cols
    row = Math.floor(ix / cols)
    dx = col * (fretboard_width_with_gutter + canvas_gutter) + canvas_gutter / 2
    dy = header_height + row * (fretboard_height_with_gutter + canvas_gutter + diagram_title_height) + canvas_gutter / 2
    ctx.save()
    ctx.translate dx, dy + diagram_title_height
    ctx.font = '20px Impact'
    ctx.font = '5pt Times' if draw_diagrams
    ctx.fillStyle = 'rgb(10,20,30)'
    ctx.fillText note_names[note_number] + ' ' + title, h_gutter, -3
    draw_fingerboard()
    for semitones, si in outervals
      continue if semitones in intervals
      draw_intervals_from semitones, string, fret, other_colors[si]
    for semitones, si in intervals
      draw_intervals_from semitones, string, fret, colors[si]
    ctx.restore()

  unless pdf
    filename = "test.pdf"
    fs.writeFile build_directory + filename, canvas.toBuffer()

# chord_page 'Major', [0, 4, 7]

chord_book = ->
  chords = [


  for interval_name, semitones in intervals
    ix = (semitones + 11) % 12
    dx = (ix % 3) * (padded_fretboard_width + canvas_gutter) + canvas_gutter / 2
    dy = Math.floor(ix / 3) * (header_height + padded_fretboard_height + canvas_gutter)
    ctx.save()
    ctx.translate dx, dy
    ctx.translate 0, header_height
