         }
     }
     
-    @IBInspectable var color: NSColor = defaultStrokeColor {
+    @IBInspectable var color: NSColor = NSColor.whiteColor() {
         didSet {
             progressLayer.strokeColor = color.CGColor
         }
     }
     
-    @IBInspectable var backgroundColor: NSColor = defaultBackgroundColor {
+    @IBInspectable var backgroundColor: NSColor = NSColor(calibratedWhite: 0.07, alpha: 0.7) {
         didSet {
             backgroundLayer.backgroundColor = backgroundColor.CGColor
         }
     }
 
-    let lengthRatio = (0.0, 0.8)
-    let duration = 1.5
-
     //MARK: Shape Layer
-    var backgroundLayer: CAShapeLayer = {
-        var tempLayer = CAShapeLayer()
-        tempLayer.fillColor = defaultBackgroundColor.CGColor
-        return tempLayer
-    }()
+    var backgroundLayer = CAShapeLayer()
 
     var progressLayer: CAShapeLayer = {
         var tempLayer = CAShapeLayer()
         tempLayer.strokeColor = defaultStrokeColor.CGColor
-        tempLayer.strokeEnd = 0.8
+        tempLayer.strokeEnd = CGFloat(strokeRange.end)
         tempLayer.lineCap = kCALineCapRound
         tempLayer.fillColor = NSColor.clearColor().CGColor
         return tempLayer

import Foundation
import Cocoa

private let defaultBackgroundColor = NSColor(calibratedWhite: 0.07, alpha: 0.7)
private let defaultStrokeColor = NSColor.whiteColor()

@IBDesignable
class CircularSnail: IndeterminateAnimation {

        tempRotation.fromValue = 0
        tempRotation.toValue = 1
        tempRotation.cumulative = true
        tempRotation.duration = duration / 2
        return tempRotation
        }()

    func makeLayers() {
        self.wantsLayer = true
        let rect = self.bounds
        backgroundLayer.cornerRadius = rect.midX
        backgroundLayer.frame = rect
        backgroundLayer.backgroundColor = backgroundColor.CGColor
        self.layer?.addSublayer(backgroundLayer)
        
        // Progress Layer
        let radius = (rect.width / 2) * 0.75
        progressLayer.frame =  rect
        progressLayer.lineWidth = lineWidth == -1 ? radius / 10: lineWidth
        var arcPath = NSBezierPath()
        arcPath.appendBezierPathWithArcWithCenter(rect.mid, radius: radius, startAngle: 0, endAngle: 360, clockwise: false)
        progressLayer.path = arcPath.CGPath
        backgroundLayer.addSublayer(progressLayer)
    }
    
    
    //MARK: Initialization
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        makeStrokeAnimations()
        makeLayers()
    }

    var currentRotation = 0.0
    let π2 = M_PI * 2
    override func animationDidStop(anim: CAAnimation!, finished flag: Bool) {
        if !animate { return }
        CATransaction.begin()
        CATransaction.setDisableActions(true)
        currentRotation += strokeRange.end * π2
        currentRotation %= π2
        progressLayer.setAffineTransform(CGAffineTransformMakeRotation(CGFloat( currentRotation)))
        CATransaction.commit()
        progressLayer.addAnimation(animationGroup, forKey: "strokeEnd")
    }
