         path.push current
 
     mouseup: (e) ->
+
+clipMask = (target, maskPath) ->
+  # Apply the mask
+  c = document.createElement "canvas"
+  c.width = target.naturalWidth
+  c.height = target.naturalHeight
+  ct = c.getContext('2d')
+  applyClip(ct, maskPath)
+  ct.drawImage(target, 0, 0)
+  target.parentElement.appendChild(c)
+
+  # Apply the negative
+  c = document.createElement "canvas"
+  c.width = target.naturalWidth
+  c.height = target.naturalHeight
+  ct = c.getContext('2d')
+  ct.drawImage(target, 0, 0)
+  applyClip(ct, maskPath)
+  ct.globalCompositeOperation = "destination-out"
+  ct.fillStyle = "#000"
+  ct.fillRect(0, 0, c.width, c.height)
+  target.parentElement.appendChild(c)
+
+  target.remove()
+
+applyClip = (ct, maskPath) ->
+  maskPath.forEach ({x, y}, i) ->
+    if i is 0
+      ct.beginPath()
+      ct.moveTo(x, y)
+    else
+      ct.lineTo(x, y)
+
+  ct.closePath()
+  ct.clip()
 
 drawCircle = (context, p) ->
   context.beginPath()

      context = canvas.getContext('2d')

      targetMap.forEach (intersections, target) ->
        if intersections.length >= 2
          [beginPathIndex, endImageEdge] = intersections.shift()
          [endPathIndex, beginImageEdge] = intersections.shift()

            maskPath.push path[beginPathIndex]
            drawLine(context, line, "#0F0")

          clipMask(target, maskPath)

        return

