         sprite.at 1, x: 400, y: 50
 
     animation.make_sprite
+      visible: not just_one
       draw: ->
         draw_title title
         , font: '20px Impact', fillStyle: 'rgb(128, 128, 128)'
-        , x: 0, y: 0, gravity: 'top'
+        , gravity: 'top'
 
-    for i in [0...12]
-      do (pitch=i) ->
-        t0 = pitch
-        chord_name = compute_chord_name pitch, chord
-        fingering = best_fingering_for(chord, pitch)
-        pos = sprite_position_at master_diagram, t0
-        [col, row] = [i % 4 , Math.floor(i / 4)]
+    [0...12].forEach (i) ->
+      return if i > 0 and just_one
+      t0 = pitch = i
+      chord_name = compute_chord_name pitch, chord
+      name = "#{chord_name} Major"
+      fingering = best_fingering_for chord, pitch
+      pos = sprite_position_at master_diagram, t0
+      [col, row] = [i % 4 , Math.floor(i / 4)]
 
-        animation.make_sprite
-          t0: t0
-          draw: (ctx, dt) ->
-            draw_title "#{chord_name} Major", font: '12pt Times', fillStyle: 'black', y: -3
-            draw_chord_diagram ctx, fingering.positions, barres: fingering.barres
+      animation.make_sprite
+        name: name
+        t0: t0
+        draw: (ctx, dt) ->
+          draw_title name, font: '12pt Times', fillStyle: 'black', y: -3
+          draw_chord_diagram ctx, fingering.positions, barres: fingering.barres
 
-        , (sprite) ->
-          sprite.at 0, pos
-          sprite.at 1, x: 50 + col * 130, y: pos.y + 100 + row * 115
+      , (sprite) ->
+        # sprite.at t0, visible: true
+        sprite.at 0, pos
+        sprite.at 0.5, pos
+        # sprite.at 1, pos
+        sprite.at 1, x: 50 + col * 130, y: pos.y + 100 + row * 115
 
 module.exports = chord_shape_flipbook


ease = (s, x0, x1) ->x0 + s * (x1 - x0)

easeAttr = (path, aname, s, defaultValue) ->
  return defaultValue unless path and aname of path[0]
  ease(s, path[0][aname], path[1][aname])

sprite_position_at = (sprite, t) ->
  s = Math.min(1, (t - sprite.t0) / (sprite.t1 - sprite.t0))
  s = Math.min(1, t - sprite.t0) unless 't1' of sprite
  {
    x: easeAttr(sprite.path, 'x', s, 0)
    y: easeAttr(sprite.path, 'y', s, 0)
  }

write_animation_frames = (options) ->
  {step_size, sprites, end_padding} = options
  step_size ||= 1
  t_end = Math.max(_.chain(sprites).pluck('t1').compact().value()...)
  t_end += (end_padding or 0)
  t = 0
  with_book (options.title || "animation frames"), (book) ->
    ctx = book.context
    while t < t_end
      book.add_page ->
        with_page width: 640, height: 480, ->
          current_sprites = (sprite for sprite in sprites when (sprite.t0 or 0) <= t < (sprite.t1 or t_end))
          for sprite in _.sortBy(current_sprites, (s) -> (s.z_index or 0))
            s = Math.min(1, (t - sprite.t0) / (sprite.t1 - sprite.t0))
            s = t - sprite.t0 unless sprite.t1
            {x, y} = sprite_position_at(sprite, t)
            with_graphics_context (ctx) ->
              ctx.translate x, y
              sprite.draw ctx, s

  , (animation) ->

    master_diagram = animation.make_sprite
      name: "master"
      t0: 0
      t1: 13
      z_index: 1
      visible: not just_one
      draw: (ctx, s) ->
        s *= 12
        pitch = Math.floor s
        pitch = Math.min 11, pitch
        bend = s - pitch
        positions = finger_positions_on_chord chord, pitch
        draw_chord_diagram ctx, positions, dy: bend * ChordDiagramStyle.fret_height

        pitch = (pitch + 1) % 12
        bend -= 1
        positions = finger_positions_on_chord chord, pitch
        draw_chord_diagram ctx, positions, dy: bend * ChordDiagramStyle.fret_height

      , (sprite) ->
