     var handles:[Handle] = []
     var guides:[Handle] = []
 
-    init() {
-        self.curve = BezierCurve(start:CGPoint(x:100,y:100), control1:CGPoint(x:150,y:150), end:CGPoint(x:200,y:100))
+    init(_ curve:BezierCurve) {
+        self.curve = curve
         self.handles = self.curve.points.map {
             (p:CGPoint) -> Handle in
             return Handle(position:p)
-            }    
+        }
         self._update()
     }
     

    override func mouseDragged(theEvent: NSEvent) {
        if let activeHandle = activeHandle {
            let location = self.convertPoint(theEvent.locationInWindow, fromView:nil)
            self.editor.setHandlePosition(activeHandle, position:location)
            self.needsDisplay = true
        }
    }

    override func mouseUp(theEvent: NSEvent) {
        self.activeHandle = nil
        self.needsDisplay = true
    }

    func handleHit(point:CGPoint) -> Int? {
        for (index, handle) in enumerate(self.editor.handles) {
            let R = CGFloat(10.0)
            let handleRect = CGRect(x:handle.position.x - R, y:handle.position.y - R, width:R * 2, height:R * 2)
            if handleRect.contains(point) {
                return index
            }
        }
        return nil

        NSColor.blackColor().set()

        let context = NSGraphicsContext.currentContext()!.CGContext
        for curve in self.curves {
            curve.draw(context)
        }
    }
    
    override func mouseDown(theEvent: NSEvent) {
        let location = self.convertPoint(theEvent.locationInWindow, fromView:nil)
        if let (curve, index) = handleHit(location) {
            activeCurve = curve
            activeHandle = index
            self.needsDisplay = true
        }
