// Example of hex initializer
let sun = UIColor(hex: "#FBF002")
// Example of RGB 0-255 initializer
let pink = UIColor(r: 241, g: 126, b: 177)
let container = UIView(frame: CGRect(x: 0, y: 0, width: 888, height: 250))
container.backgroundColor = pink
let label = UILabel(frame: container.frame)
label.text = "Sweet"
label.textColor = sun
// Example of overlay similar to Photoshop with reduced alpha
// This allows us to get a more natural ambient shadow
label.layer.shadowColor = pink.overlayBlack.with(alpha: 0.6).cgColor
Comapre if two colors are equal. When strict is false, color within 1% of the comparing color is considered equal.
Get the red, green, blue and alpha values. (0-1).
Get the 8 bit red, green, blue and alpha values. (0-255).
Get the hue, saturation, brightness and alpha values. (0-1).
Get the 8 bit hue, saturation, brightness and alpha values. (0-255).
Get the CIE XYZ values.
Get the CIE L*ab values.
Get the relative luminosity value of the color. This follows the W3 specs of luminosity to give weight to colors which humans perceive more of.
Determine if the color is dark based on the relative luminosity of the color.
Determine if the color is light based on the relative luminosity of the color.
Determine if this colors is darker than the compared color based on the relative luminosity of both colors.
Determine if this colors is lighter than the compared color based on the relative luminosity of both colors.
Determine if this color is either black or white.
Detemine the distance between two colors based on the way humans perceive them. Uses the CIE94 algorithm.
Detemine the distance between two colors based on the way humans perceive them. Uses the Sharma 2004 alteration of the CIEDE2000 algorithm.
Determine the contrast ratio between two colors. A low ratio implies there is a smaller contrast between the two colors. A higher ratio implies there is a larger contrast between the two colors.
Determine if two colors are contrasting or not based on the W3 standard.
Get either black or white to contrast against a color.
Get a clone of this color with a different alpha value.
Get a new color with an overlay blend mode on top of this color. This is similar to Photoshop's overlay blend mode.
Get a new color if a black overlay was applied.
Get a new color if a white overlay was applied.
Get a new color with a multiply blend mode on top of this color. This is similar to Photoshop's multiply blend mode.
Get a new color with a screen blend mode on top of this color. This is similar to Photoshop's screen blend mode.
Get the complement of this color on the hue wheel.