             }
         }
     }
-    
-    
+}
+
+
+extension ViewController : SettingsPopoverDelegate {
     
     func settingsPopover(_ settingsPopover: SettingsPopover, didSelectIndex index: Int) {
         let color = self.settingsPopover(settingsPopover, colorAt: index)

    
    func toggleSettingsPopover() {
        
        guard let popover = self.settingsPopover else {
            fatalError()
        }
        
        UIView.animate(withDuration: 0.10) {
            if popover.alpha > 0 {


import UIKit

class ViewController: UIViewController {
    
    static let numColors = 16
    static let numColumns = 4
    
    @IBOutlet var settingsButton: UIButton?
    let saturation = 60 // 0-100
    let brightness = 85 // 0-100
    
    lazy var settingsPopover : SettingsPopover = {
        
        if !self.isViewLoaded {
            fatalError()
