//
//  SearchFilterButtonsDark.swift
//  Balance
//
//  Created by Christian Baroni on 1/30/17.
//  Copyright © 2017 Balance. All rights reserved.
//
//  Generated by PaintCode
//  http://www.paintcodeapp.com
//



import Cocoa

struct SearchFilterButtonsDark {

    //// Drawing Methods

    static func drawButton(frame: NSRect = NSRect(x: 0, y: 0, width: 191, height: 36), buttonBackgroundColor: NSColor?) {
        //// General Declarations
        let context = NSGraphicsContext.current!.cgContext
        // This non-generic function dramatically improves compilation times of complex expressions.
        func fastFloor(_ x: CGFloat) -> CGFloat { return floor(x) }

        //// Color Declarations
        let buttonBackground = buttonBackgroundColor ?? NSColor(deviceRed: 0.275, green: 0.318, blue: 0.361, alpha: 1)
        let buttonDarkBackground = NSColor(deviceRed: 0, green: 0, blue: 0, alpha: 0.1)
        let buttonBorderColor = NSColor(deviceRed: 1, green: 1, blue: 1, alpha: 0.04)
        let transparentBackground = NSColor(deviceRed: 0.145, green: 0.165, blue: 0.192, alpha: 0.06)

        //// Shadow Declarations
        let buttonShadowLarge = NSShadow()
        buttonShadowLarge.shadowColor = NSColor.black.withAlphaComponent(0.09)
        buttonShadowLarge.shadowOffset = NSSize(width: 0, height: -1.5)
        buttonShadowLarge.shadowBlurRadius = 3
        let buttonShadowSmall = NSShadow()
        buttonShadowSmall.shadowColor = NSColor.black
        buttonShadowSmall.shadowOffset = NSSize(width: 0, height: -1)
        buttonShadowSmall.shadowBlurRadius = 1


        //// Subframes
        let group2: NSRect = NSRect(x: frame.minX + 3, y: frame.minY + 4, width: frame.width - 6, height: frame.height - 6)
        let group: NSRect = NSRect(x: frame.minX + 3, y: frame.minY + 4, width: frame.width - 6, height: frame.height - 6)


        //// Group 2
        //// extraShadow Drawing
        let extraShadowPath = NSBezierPath(roundedRect: NSRect(x: group2.minX + fastFloor(group2.width * 0.00000 + 0.5), y: group2.minY + fastFloor(group2.height * 0.00000 + 0.5), width: fastFloor(group2.width * 1.00000 + 0.5) - fastFloor(group2.width * 0.00000 + 0.5), height: fastFloor(group2.height * 1.00000 + 0.5) - fastFloor(group2.height * 0.00000 + 0.5)), xRadius: 6, yRadius: 6)
        NSGraphicsContext.saveGraphicsState()
        buttonShadowSmall.set()
        transparentBackground.setFill()
        extraShadowPath.fill()
        NSGraphicsContext.restoreGraphicsState()



        //// rectangle Drawing
        let rectanglePath = NSBezierPath(roundedRect: NSRect(x: group2.minX + fastFloor(group2.width * 0.00000 + 0.5), y: group2.minY + fastFloor(group2.height * 0.00000 + 0.5), width: fastFloor(group2.width * 1.00000 + 0.5) - fastFloor(group2.width * 0.00000 + 0.5), height: fastFloor(group2.height * 1.00000 + 0.5) - fastFloor(group2.height * 0.00000 + 0.5)), xRadius: 6, yRadius: 6)
        NSGraphicsContext.saveGraphicsState()
        buttonShadowLarge.set()
        buttonBackground.setFill()
        rectanglePath.fill()
        NSGraphicsContext.restoreGraphicsState()
        
        //// Clip borderMask
        let borderMaskPath = NSBezierPath(roundedRect: NSRect(x: group.minX + fastFloor(group.width * 0.00000 + 0.5), y: group.minY + fastFloor(group.height * 0.00000 + 0.5), width: fastFloor(group.width * 1.00000 + 0.5) - fastFloor(group.width * 0.00000 + 0.5), height: fastFloor(group.height * 1.00000 + 0.5) - fastFloor(group.height * 0.00000 + 0.5)), xRadius: 6, yRadius: 6)
        
        
        // Darken the items after the top one
        let darkFrame = NSRect(x: frame.minX + 3, y: frame.minY + 4 + 30, width: frame.width - 6, height: frame.height - 6 - 30)
        let darkPath = NSBezierPath(rect: darkFrame)
        NSGraphicsContext.saveGraphicsState()
        borderMaskPath.addClip()
        buttonDarkBackground.setFill()
        darkPath.fill()
        NSGraphicsContext.restoreGraphicsState()


        //// Group
        NSGraphicsContext.saveGraphicsState()
        context.beginTransparencyLayer(auxiliaryInfo: nil)

        
        //// buttonBorder Drawing
        let buttonBorderPath = NSBezierPath(roundedRect: NSRect(x: group.minX + fastFloor(group.width * 0.00000 + 0.5), y: group.minY + fastFloor(group.height * 0.00000 + 0.5), width: fastFloor(group.width * 1.00000 + 0.5) - fastFloor(group.width * 0.00000 + 0.5), height: fastFloor(group.height * 1.00000 + 0.5) - fastFloor(group.height * 0.00000 + 0.5)), xRadius: 6, yRadius: 6)
        borderMaskPath.addClip()
        buttonBorderColor.setStroke()
        buttonBorderPath.lineWidth = 1
        buttonBorderPath.stroke()


        context.endTransparencyLayer()
        NSGraphicsContext.restoreGraphicsState()
    }

}
