iTunes style color fetcher for NSImage. This is based on Panic's OS X ColorArt for iOS Swift.
In other words, it fetches the most dominant and prominent colors.
Asynchronous example:
let image = NSImage(named: "yeezus.png")
image.getColors { colors in
  backgroundView.backgroundColor = colors.background
  mainLabel.textColor = colors.primary
  secondaryLabel.textColor = colors.secondary
  detailLabel.textColor = colors.detail
}Synchronous example:
let colors = NSImage(named: "yeezus.png").colors
backgroundView.backgroundColor = colors.background
mainLabel.textColor = colors.primary
secondaryLabel.textColor = colors.secondary
detailLabel.textColor = colors.detailgetColors() -> NSImageColorsReturns a NSImageColors object. The sample image is rescaled to a width of 250px and the aspect ratio height. This blocks the main thread.
getColors(scaleDownSize: CGSize) -> NSImageColorsReturns a NSImageColors object with a custom image rescale. Use smaller sizes for better performance at the cost of quality colors. Use larger sizes for better color sampling and quality at the cost of performance. This blocks the main thread.
getColors(completionHandler: (NSImageColors) -> Void) -> VoidPasses a NSImageColors object into the closure. The sample image is rescaled to a width of 250px and the aspect ratio height. This runs on the background thread.
getColors(scaleDownSize: CGSize, completionHandler: (NSImageColors) -> Void) -> VoidPasses a NSImageColors object into the closure, with a custom image rescale. Use smaller sizes for better performance at the cost of quality colors. Use larger sizes for better color sampling and quality at the cost of performance. This runs on the background thread.
NSImageColors is struct that contains four different NSColors.
var background
var primary
var secondary
var detailThe license is provided in the project folder. Please also refer to Panic's original license.
June 2015 - Toronto
