   stream.on 'data', (chunk) -> out.write(chunk)
   stream.on 'end', () -> console.log "Saved #{fname}"
 
-intervals_from = (root_string, root_fret, semitones) ->
-  root_note_number = note_number_at(root_string, root_fret)
+intervals_from = (fingering, semitones) ->
+  root_note_number = fingering_note_number(fingering)
   fingerings = []
-  for string in strings
-    for fret in frets
-      continue unless (note_number_at(string, fret) - root_note_number + 120) % 12 == semitones
-      fingerings.push string: string, fret: fret
+  finger_positions_each (fingering) ->
+    return unless (fingering_note_number(fingering) - root_note_number + 120) % 12 == semitones
+    fingerings.push fingering
   return fingerings
 
-draw_intervals_from = (semitones, root_string, root_fret, color) ->
-  root_note_number = note_number_at(root_string, root_fret)
-  draw_note root_string, root_fret, true, color
-  for {string, fret} in intervals_from(root_string, root_fret, semitones)
-    continue if string == root_string and fret == root_fret
-    draw_note string, fret, false, color
+draw_intervals_from = (root_fingering, semitones, color) ->
+  root_note_number = fingering_note_number(root_fingering)
+  draw_fingering root_fingering, is_root: true #, color: color
+  for fingering in intervals_from(root_fingering, semitones)
+    continue if fingering.string == root_fingering.string and fingering.fret == root_fingering.fret
+    draw_fingering fingering, color: color
 
 interval_cards = ->
-  fingerings_each (string, fret) ->
+  finger_positions_each (string, fret) ->
     canvas = new Canvas(padded_fretboard_width, padded_fretboard_height)
     ctx = canvas.getContext('2d')
     erase_background()
     draw_fingerboard()
-    draw_note string, fret
+    draw_note string_number: string, fret_number: fret
     filename = "#{string}-#{fret}.png"
     save_canvas_to_png canvas, filename
 

    ctx.moveTo h_gutter, y
    ctx.lineTo h_gutter + fret_count * fret_width + fret_overhang, y
    ctx.lineWidth = 1
    ctx.lineWidth = 0.5 if hidden_strings.indexOf(n) >= 0
    ctx.stroke()

draw_frets = ->

    ctx.addPage()
  fs.writeFile build_directory + filename, canvas.toBuffer()

Chords = [
  {name: 'Major', abbr: '', offsets: [0, 4, 7]},
  {name: 'Minor', abbr: 'm', offsets: [0, 3, 7]},
  {name: 'Aug', abbr: '+', offsets: [0, 4, 8]},
  {name: 'Dim', abbr: '°', offsets: [0, 3, 6]},
  {name: 'Sus2', abbr: 'sus2', offsets: [0, 2, 7]},
  {name: 'Sus4', abbr: 'sus4', offsets: [0, 5, 7]},
  {name: 'Dom 7th', abbr: '7', offsets: [0, 4, 7, 10]},
  {name: 'Major 7th', abbr: 'maj7', offsets: [0, 4, 7, 11]},
  {name: 'Minor 7th', abbr: 'min7', offsets: [0, 3, 7, 10]},
  {name: 'Dim 7th', abbr: '°7', offsets: [0, 3, 6, 9]},
  {name: 'Dom 7 b5', abbr: '7b5', offsets: [0, 4, 6, 10]},
  {name: 'Min 7th b5', abbr: 'm7b5', offsets: [0, 3, 6, 10]},
  # {name: 'Aug 7th', abbr: '7aug', offsets: [0, 4, 8, 10]},
  {name: 'Dim Maj 7th', abbr: '°maj7', offsets: [0, 3, 6, 11]},
  {name: 'Min Maj 7th', abbr: 'min-maj7', offsets: [0, 3, 7, 11]},
  # {name: '6th', abbr: '6', offsets: [0, 4, 7, 9]},
]

chord_book = ->
  book "Combined Fretboard Chords.pdf", (page) ->
    for chord in Chords
      page -> chord_page chord

# chord_page Chords[0]
# chord_book()
intervals_book by_root: false
