         
         drawLine context, line, "purple"
 
-        targetSet.forEach (target) ->
+        targetMap.forEach (intersections, target) ->
           rectLines(target).forEach (targetLine) ->
             intersection = line.intersects(targetLine)
 
             if intersection
               drawCircle context, intersection
+
+              intersections.push path.length
+              path.push intersection
 
         path.push current
 

  cut: do ->
    path = []
    active = false
    targetSet = null

    document.addEventListener 'mouseup', () ->
      return unless active

      # Find the first two intersections of the path and the image boundary
      # Create a path and a complement path
      # split into two
      
      canvas = document.querySelector('canvas')
      context = canvas.getContext('2d')

      targetMap.forEach (intersections, target) ->
        if intersections.length >= 2
          beginPathIndex = intersections.unshift()
          endPathIndex = intersections.unshift()

          i = beginPathIndex
          while i < endPathIndex
            line = Line
              start: path[i]
              end: path[i+1]
            drawLine(context, line, "#0F0")
            i += 1

    name: "Cut"
    mousedown: (e) ->
      active = true
      targetMap = new Map

      path = [Point localPosition(e, false)]

    mousemove: (e) ->
