Skip to content

jonathanzong/SwiftMaterialPalette

Repository files navigation

SwiftMaterialPalette

Generates a palette by extracting color swatches from an image.

SwiftMaterialPalette is a Swift port of Android's Palette class.

Inspired by Vibrant.js.

##Demo

##Installation

CocoaPods is a dependency manager for Cocoa projects. You can install it by running:

$ gem install cocoapods

Specify MaterialPalette as a dependency in your Podfile:

platform :ios, "8.0"
use_frameworks!

pod 'MaterialPalette', '0.0.1'

Then, run the following command:

$ pod install

##Usage

let palette = Palette(uiImage: image)
            
let maybeSwatches = [
    palette.getVibrantSwatch(),
    palette.getMutedSwatch(),
    palette.getLightVibrantSwatch(),
    palette.getLightMutedSwatch(),
    palette.getDarkVibrantSwatch(),
    palette.getDarkMutedSwatch()]

var swatches: [Palette.Swatch] = []

for swatch in maybeSwatches {
    if let swatch = swatch {
        swatches.append(swatch)
    }
}

##License MIT

About

Generates a palette by extracting color swatches from an image.

Resources

License

Stars

Watchers

Forks

Packages

No packages published