         CGContextSetLineWidth(context, brushWidth)
         CGContextSetRGBStrokeColor(context, 0, 0, 0, 1.0)
         CGContextSetBlendMode(context, CGBlendMode.Normal)
-        
+
         CGContextStrokePath(context)
-        
+
         tempImageView.image = UIGraphicsGetImageFromCurrentImageContext()
         tempImageView.alpha = opacity
         UIGraphicsEndImageContext()
     }
-    
+
     override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
         swiped = true
         if let touch = touches.first! as UITouch? {
             let currentPoint = touch.locationInView(view)
             drawLineFrom(lastPoint, toPoint: currentPoint)
-            
+
             lastPoint = currentPoint
         }
     }
-    
+
     override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
         if !swiped {
             // draw a single point
             drawLineFrom(lastPoint, toPoint: lastPoint)
         }
-        
+
         // Merge tempImageView into mainImageView
         UIGraphicsBeginImageContext(mainImageView.frame.size)
         tempImageView.image?.drawInRect(CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height), blendMode: CGBlendMode.Normal, alpha: opacity)
         mainImageView.image = UIGraphicsGetImageFromCurrentImageContext()
         UIGraphicsEndImageContext()
-        
+
         tempImageView.image = nil
+
+        drawMidpoint()
         lineCoordinates = []
     }
+
+    func drawMidpoint() {
+        print("Drawing")
+
+        var totalX: CGFloat = 0
+        var totalY: CGFloat = 0
+
+        for coordinate in lineCoordinates {
+            totalX += coordinate[0]
+            totalY += coordinate[1]
+        }
+
+        let midpointX = totalX / CGFloat(lineCoordinates.count)
+        let midpointY = totalY / CGFloat(lineCoordinates.count)
+
+        drawCircle(midpointX, y: midpointY)
+
+        print("Done")
+    }
+
+    func drawCircle(x: CGFloat, y: CGFloat) {
+        let circlePath = UIBezierPath(arcCenter: CGPoint(x: x, y: y), radius: CGFloat(20), startAngle: CGFloat(0), endAngle: CGFloat(M_PI * 2), clockwise: true)
+
+        let shapeLayer = CAShapeLayer()
+        shapeLayer.path = circlePath.CGPath
+
+        //change the fill color
+        shapeLayer.fillColor = UIColor.clearColor().CGColor
+        //you can change the stroke color
+        shapeLayer.strokeColor = UIColor.redColor().CGColor
+        //you can change the line width
+        shapeLayer.lineWidth = 3.0
+
+        mainImageView.layer.sublayers = nil
+        mainImageView.layer.addSublayer(shapeLayer)
+
+//        UIGraphicsBeginImageContext(view.frame.size)
+//        let context = UIGraphicsGetCurrentContext()
+//
+//        let startAngle = -(M_PI / 2) // 90 degrees
+//        let endAngle = ((2 * M_PI) + startAngle)
+//
+//        CGContextSetLineCap(context, CGLineCap.Round)
+//        CGContextSetLineWidth(context, 5)
+//        CGContextSetRGBStrokeColor(context, 0, 0, 0, 1.0)
+//        CGContextSetBlendMode(context, CGBlendMode.Normal)
+//        CGContextMoveToPoint(context, midpointX, midpointY)
+////        CGContextAddArc(context, midpointX, midpointY, 20, CGFloat(startAngle), CGFloat(endAngle), 0)
+//        mainImageView.image?.drawAtPoint(CGPoint(x: midpointX, y: midpointY))
+//
+//        UIGraphicsEndImageContext()
+    }
 }

class ViewController: UIViewController {
    @IBOutlet weak var mainImageView: UIImageView!
    @IBOutlet weak var tempImageView: UIImageView!
    
    var lastPoint = CGPoint.zero
    var brushWidth: CGFloat = 2.0
    var opacity: CGFloat = 1.0

    var lineCoordinates: Array<Array<CGFloat>> = []

    let colors: [(CGFloat, CGFloat, CGFloat)] = [
            (0, 0, 0),
            (105.0 / 255.0, 105.0 / 255.0, 105.0 / 255.0),
            (1.0, 0, 0),
            (0, 0, 1.0),
            (51.0 / 255.0, 204.0 / 255.0, 1.0),
            (102.0 / 255.0, 204.0 / 255.0, 0),
            (102.0 / 255.0, 1.0, 0),
            (160.0 / 255.0, 82.0 / 255.0, 45.0 / 255.0),
            (1.0, 102.0 / 255.0, 0),
            (1.0, 1.0, 0),
            (1.0, 1.0, 1.0),
    ]

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
