Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Colors From Images

Daniel Chick edited this page Aug 30, 2017 · 2 revisions

Chameleon now supports the extraction of colors from images. You can either generate both flat and non-flat color schemes from an image, or easily extract the average color.

To generate a color scheme simply do the following:

Normal Convention:
Objective-C
[NSArray arrayOfColorsFromImage:(UIImage *)image withFlatScheme:(BOOL)flatScheme];
Swift (Array extension missing)
NSArray(ofColorsFromImage: UIImage, withFlatScheme: Bool)
Chameleon Shorthand:
Objective-C
ColorsFromImage(image, isFlatScheme)
Swift
ColorsFromImage(image, isFlatScheme)

To extract the average color from an image, you can also do:

Normal Convention:
Objective-C
[UIColor colorWithAverageColorFromImage:(UIImage *)image];
Swift
UIColor(averageColorFromImage: UIImage)
Chameleon Shorthand:
Objective-C
AverageColorFromImage(image)
Swift
AverageColorFromImage(image)