This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from CMYK (cyan, magenta, yellow, black) colors. | |
extension UIColor { | |
/// The CMYK (cyan, magenta, yellow, black) components of a color, in the range [0, 100%]. | |
struct CMYK: Hashable { | |
/// The cyan component of the color, in the range [0, 100%]. | |
var cyan: CGFloat | |
/// The magenta component of the color, in the range [0, 100%]. | |
var magenta: CGFloat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from CIELAB colors. | |
extension UIColor { | |
/// The CIELAB components of a color - lightness (L) and chromaticity (a,b). | |
struct CIELAB: Hashable { | |
/// The lightness component of the color, in the range [0, 100] (darkest to brightest). | |
var L: CGFloat | |
/// The green-red chromaticity component of the color, typically in the range [-128, 128]. | |
var a: CGFloat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from CIE 1931 XYZ colors. | |
extension UIColor { | |
/// The CIE 1931 XYZ components of a color - luminance (Y) and chromaticity (X,Z). | |
struct CIEXYZ: Hashable { | |
/// A mix of cone response curves chosen to be orthogonal to luminance and | |
/// non-negative, in the range [0, 95.047]. | |
var X: CGFloat | |
/// The luminance component of the color, in the range [0, 100]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from CIELCh° colors. | |
extension UIColor { | |
/// The CIELCh° components of a color - lightness (L), chroma (C), and hue (h). | |
struct CIELCh: Hashable { | |
/// The lightness component of the color, in the range [0, 100] (darkest to brightest). | |
var L: CGFloat | |
/// The chroma component of the color. | |
var C: CGFloat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from CIELUV colors. | |
extension UIColor { | |
/// The CIELUV components of a color - lightness (L) and chromaticity (u,v). | |
struct CIELUV: Hashable { | |
/// The lightness component of the color, in the range [0, 100] (darkest to brightest). | |
var L: CGFloat | |
/// The green-red chromaticity component of the color, typically in the range [-100, 100]. | |
var u: CGFloat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to format strings in *camel case*. | |
extension String { | |
/// A collection of all the words in the string by separating out any punctuation and spaces. | |
var words: [String] { | |
return components(separatedBy: CharacterSet.alphanumerics.inverted).filter { !$0.isEmpty } | |
} | |
/// Returns a copy of the string with the first word beginning lowercased, and the first | |
/// letter of each word thereafter is capitalized, with no intervening spaces or punctuation, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from HSL (hue, saturation, lightness) colors. | |
extension UIColor { | |
/// The HSL (hue, saturation, lightness) components of a color. | |
struct HSL: Hashable { | |
/// The hue component of the color, in the range [0, 360°]. | |
var hue: CGFloat | |
/// The saturation component of the color, in the range [0, 100%]. | |
var saturation: CGFloat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from linear RGB colors. | |
extension UIColor { | |
/// A set of non-gamma corrected linear RGB values, in the range [0, 1]. | |
typealias LinearRGB = (r: CGFloat, g: CGFloat, b: CGFloat) | |
/// The inverse companded sRGB components to get non-gamma corrected linear values, | |
/// in the range [0, 1]. | |
var linearRGB: LinearRGB { | |
var (r, g, b) = (CGFloat(), CGFloat(), CGFloat()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from Y′UV colors. | |
extension UIColor { | |
/// The Y′UV components of a color - luma (Y′) and chroma (U,V). | |
struct YUV: Hashable { | |
/// The luma component of the color, in the range [0, 1] (black to white). | |
var Y: CGFloat | |
/// The blue-difference chroma component of the color, in the range [-0.436, 0.436]. | |
var U: CGFloat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// An extension to provide conversion to and from Y′CbCr colors. | |
extension UIColor { | |
/// The Rec.601 (standard-definition) coefficients used to calculate luma. | |
private static let encoding: (r: CGFloat, g: CGFloat, b: CGFloat) = (0.299, 0.587, 0.114) | |
/// The Y′CbCr components of a color - luma (Y′) and chroma (Cb,Cr). | |
struct YCbCr: Hashable { | |
/// The luma component of the color, in the full range [0, 255] (black to white). |
NewerOlder