     }
     
     
-    // MARK: Helpers
+    // MARK: - Helpers
+    
+    
+    func adjustButtonsForGradient (gradient: String) {
+        
+        switch gradientNode.gradientType {
+            
+        case "gamut":
+            if let label = view?.viewWithTag(20) as? UILabel { label.hidden = false }
+            if let label = view?.viewWithTag(21) as? UILabel { label.hidden = true }
+            if let label = view?.viewWithTag(22) as? UILabel { label.hidden = true }
+            if let button = view?.viewWithTag(30) as? UIButton { button.setTitle("Animate: No", forState: .Normal) }
+            enableSliderForTag(50)
+            disableSliderForTag(52)
+            disableSliderForTag(54)
+            if !uiViewForTag(95)!.enabled { enableButtonForTag(94) }
+            disableButtonForTag(96)
+            disableButtonForTag(97)
+            disableButtonForTag(98)
+            disableLabelForTag(99)
+        case "linear":
+            if let label = view?.viewWithTag(20) as? UILabel { label.hidden = true }
+            if let label = view?.viewWithTag(21) as? UILabel { label.hidden = false }
+            if let label = view?.viewWithTag(22) as? UILabel { label.hidden = true }
+            if let button = view?.viewWithTag(30) as? UIButton { button.setTitle("Animate: No", forState: .Normal) }
+            disableSliderForTag(50)
+            disableSliderForTag(52)
+            disableSliderForTag(54)
+            if !uiViewForTag(95)!.enabled { enableButtonForTag(94) }
+            enableButtonForTag(96)
+            enableButtonForTag(97)
+            enableButtonForTag(98)
+            enableLabelForTag(99)
+        case "radial":
+            if let label = view?.viewWithTag(20) as? UILabel { label.hidden = true }
+            if let label = view?.viewWithTag(21) as? UILabel { label.hidden = true }
+            if let label = view?.viewWithTag(22) as? UILabel { label.hidden = false }
+            if let button = view?.viewWithTag(30) as? UIButton { button.setTitle("Animate: No", forState: .Normal) }
+            disableSliderForTag(50)
+            enableSliderForTag(52)
+            enableSliderForTag(54)
+            disableButtonForTag(94)
+            enableButtonForTag(96)
+            enableButtonForTag(97)
+            enableButtonForTag(98)
+            enableLabelForTag(99)
+        case "sweep":
+            if let label = view?.viewWithTag(20) as? UILabel { label.hidden = false }
+            if let label = view?.viewWithTag(21) as? UILabel { label.hidden = true }
+            if let label = view?.viewWithTag(22) as? UILabel { label.hidden = true }
+            if let button = view?.viewWithTag(30) as? UIButton { button.setTitle("Animate No", forState: .Normal) }
+            enableSliderForTag(50)
+            disableSliderForTag(52)
+            disableSliderForTag(54)
+            if !uiViewForTag(95)!.enabled { enableButtonForTag(94) }
+            enableButtonForTag(96)
+            enableButtonForTag(97)
+            enableButtonForTag(98)
+            enableLabelForTag(99)
+        default: return
+        }
+    }
+    
+    
+    func uiViewForTag (tag: Int) -> UIButton? {
+        
+        if let button = view?.viewWithTag(tag) as? UIButton { return button }
+        else { return nil }
+    }
+    
+    
+    func disableButtonForTag (tag: Int) {
+        
+        if let button = (view?.viewWithTag(tag) as? UIButton) {
+            button.enabled = false
+            button.layer.borderColor = UIColor.lightGrayColor().CGColor!
+            button.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
+        }
+    }
+    
+    
+    func disableLabelForTag (tag: Int) {
+        
+        if let label = (view?.viewWithTag(tag) as? UILabel) {
+            label.enabled = false
+            label.layer.borderColor = UIColor.lightGrayColor().CGColor!
+            label.textColor = UIColor.lightGrayColor()
+        }
+    }
+    
+    
+    func disableSliderForTag (tag: Int) {
+        
+        if let slider = view?.viewWithTag(tag) as? UISlider {
+            if slider.userInteractionEnabled {
+                slider.userInteractionEnabled = false
+                slider.minimumTrackTintColor = UIColor.lightGrayColor()
+                slider.maximumTrackTintColor = UIColor.lightGrayColor()
+                
+                if let label = view?.viewWithTag(tag + 1) as? UILabel {
+                    label.textColor = UIColor.lightGrayColor()
+                }
+            }
+        }
+    }
+    
+    
+    func enableButtonForTag (tag: Int) {
+        
+        if let button = (view?.viewWithTag(tag) as? UIButton) {
+            button.enabled = true
+            button.layer.borderColor = blue.CGColor!
+            button.setTitleColor(blue, forState: .Normal)
+        }
+    }
+    
+    
+    func enableLabelForTag (tag: Int) {
+        
+        if let label = (view?.viewWithTag(tag) as? UILabel) {
+            label.enabled = true
+            label.layer.borderColor = blue.CGColor!
+            label.textColor = blue
+        }
+    }
+    
+    
+    func enableSliderForTag (tag: Int) {
+        
+        if let slider = view?.viewWithTag(tag) as? UISlider {
+            if slider.userInteractionEnabled == false {
+                slider.userInteractionEnabled = true
+                slider.minimumTrackTintColor = blue
+                slider.maximumTrackTintColor = UIColor.darkGrayColor()
+                
+                if let label = view?.viewWithTag(tag + 1) as? UILabel {
+                    label.textColor = blue
+                }
+            }
+        }
+    }
+    
+    
+    func resetCurrentNode () {
+        
+        gradientNode.removeAllActions()
+        
+        if let button = view?.viewWithTag(30) as? UIButton { button.setTitle("Animate: No", forState: .Normal) }
+        
+        switch gradientNode.gradientType {
+            
+        case "gamut": gamutGradientButtonPressed()
+        case "linear": linearGradientButtonPressed()
+        case "sweep": sweepGradientButtonPressed()
+        case "radial": radialGradientButtonPressed()
+        default: return
+        }
+    }
+    
+    
+    /**
+    
+    Creates an array of the given number of random colors.
+    
+    :param: numberOfColors The number of colors that will be in the array.
+    
+    :returns: An array of the given number of random colors.
+    
+    */
+    func randomColorArray(numberOfColors: Int) -> [UIColor] {
+        
+        var newColors = [UIColor]()
+        
+        for var i = 0; i < numberOfColors; i++ {
+            
+            let newColor = UIColor(hue: random(min: 0.0, max: 1.0), saturation: random(min: 0.33, max: 1.0), brightness: random(min: 0.75, max: 1.0), alpha: 1.0)
+            newColors.append(newColor)
+        }
+        
+        return newColors
+    }
+    
+    
+    /**
+    
+    Generates a random CGFloat between the given min and max.
+    
+    :param: min The lowest possible return value.
+    
+    :param: max The highest possible return value.
+    
+    :returns: A random CGFloat between the given min and max.
+    
+    */
+    func random(#min: CGFloat, max: CGFloat) -> CGFloat {
+        
+        let random = CGFloat(Float(arc4random()) / 0xFFFFFFFF)
+        return random * (max - min) + min
+    }
+    
+    
+    /**
+    
+    The angle of a point around (0.5, 0.5).
+    
+    */
+    func angleOfPoint (point: CGPoint) -> CGFloat {
+        
+        var newPoint = point
+        newPoint.x -= 0.5
+        newPoint.y -= 0.5
+        
+        return abs(atan2(newPoint.x, newPoint.y) - CGFloat(M_PI))
+    }
+    
     
     /**
     

    
    // MARK: - Actions
    
    
    // MARK: Gradients
    

        
        return sqrt(pow(xDistance, 2) + pow(yDistance, 2))
    }
    
    
    /**
    
    A random roll for 1.0 or -1.0
    
    :returns: Either 1.0 or -1.0 with 50/50 probability.
    
    */
    func randomPlusMinus () -> CGFloat {
        
        let randomNumber = random(min: 0.0, max: 1.0)
        if randomNumber >= 0.5 {
            return 1.0
        } else {
            return -1.0
        }
    }
    
    
    /**
    
    Rotates a point around (0.5, 0.5) by the given angle.
    
    :param: point The starting point.
    
    :param: angle The angle by which the point will be rotated in radians.
    
    :returns: A point rotated from the starting point, around (0.5, 0.5), by the given angle.
    
    */
    func rotatePoint (point: CGPoint, byAngle angle: CGFloat) -> CGPoint {
        
        let sinAngle = sin(angle)
        let cosAngle = cos(angle)
        
        var newPoint = point
        newPoint.x -= 0.5
        newPoint.y -= 0.5
        
        newPoint.x = newPoint.x * cosAngle - newPoint.y * sinAngle
        newPoint.y = newPoint.x * sinAngle + newPoint.y * cosAngle
        
        newPoint.x += 0.5
        newPoint.y += 0.5
        
        return newPoint
    }
}
