TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✓ |
Maintained by Michał Tynior.
Felucia provides useful extensions to UIColor.
You can use The Swift Package Manager to install Felucia by adding it to your Package.swift file:
import PackageDescription
let package = Package(
name: "MyApp",
targets: [],
dependencies: [
.Package(url: "https://github.com/mtynior/Felucia.git", majorVersion: 1)
]
)
You can also manually add Felucia to you project:
Felucia.swift
file,Felucia.swift
into you project's tree.UIColor(hexARGB: "#fff")
UIColor(hexARGB: "fff")
UIColor(hexARGB: "#e2f5d3")
UIColor(hexARGB: "e2f5d3")
UIColor(hexARGB: "#ffe2f5d3")
UIColor(hexARGB: "ffe2f5d3")
UIColor(r: 255, g: 128, b: 64, a: 255)
UIColor(r: 255, g: 128, b: 64)
UIColor(red: 1.0, green: 0.5, blue: 0.25, alpha: 1.0)
UIColor(red: 1.0, green: 0.5, blue: 0.25)
UIColor(cyan: 0, magneta: 0.5, yellow: 0.75, black: 0.498)
The h
can be set as value in [0, 1] or [0, 360].
The s
can be set as value in l
are in [0, 1] or [0, 100].
The a
can be set as value in [0, 1].
UIColor(h: 157.0, s: 24, l: 51)
UIColor(h: 0.436, s: 0.24, l: 0.51)
UIColor(h: 0.436, s: 0.24, l: 0.51, a: 1.0)
UIColor(r: 255, g: 128, b: 64, a: 255).rgba() // (r: 255, g: 128, b: 64, a: 255)
UIColor(r: 255, g: 128, b: 64, a: 255).rgbaArray() // [255, 128, 64, 255]
UIColor(r: 255, g: 128, b: 64, a: 255).rgbaf() // (r: 1.0, g: 0.5, b: 0.25, a: 1.0)
UIColor(r: 255, g: 128, b: 64, a: 255).rgbafArray() // [1.0, 0.5, 0.25, 1.0]
UIColor(r: 255, g: 128, b: 64, a: 255).hsba() // (h: 0.056, s: 0.749, b: 1.0, a: 1.0)
UIColor(r: 255, g: 128, b: 64, a: 255).hsbaArray() // [0.056, 0.749, 1.0, 1.0]
UIColor(r: 255, g: 128, b: 64, a: 255).hsla() // (h: 0.0558464, s: 1.0, l: 0.62549, a: 1.0)
UIColor(r: 255, g: 128, b: 64, a: 255).hslaArray() // [0.0558464, 1.0, 0.62549, a:1.0]
UIColor(r: 255, g: 128, b: 64, a: 255).cmyk() // (c: 0.0, m: 0.498, y: 0.749, k: 0.0)
UIColor(r: 255, g: 128, b: 64, a: 255).cmykArray() // [0.0, 0.498, 0.749, 0.0]
Returns complementary color.
let color = UIColor.whiteColor().complementaryColor()
color.rgba() // (r: 0, g: 0, b: 0, a: 255)
Lightens the color a given amount, from 0.0 to 1.0. Providing 1.0 will always return white.
let color = UIColor.redColor().lighten()
color.rgba() // (r: 255, g: 51, b: 51, a: 255)
let color = UIColor.redColor().lighten(1.0)
color.rgba() // (r: 255, g: 255, b: 255, a: 255)
Darkens the color a given amount, from 0.0 to 1.0. Providing 1.0 will always return black.
let color = UIColor.redColor().darken()
color.rgba() // (r: 204, g: 0, b: 0, a: 255)
let color = UIColor.redColor().darken(1.0)
color.rgba() // (r: 0, g: 0, b: 0, a: 255)
Desaturates a color into greyscale.
let color = UIColor(r: 67, g: 122, b: 134).grayscale()
color.rgba() // (r: 106, g: 106, b: 106, a: 255)
Returns true
when the color's perceived brightness is light.
UIColor.whiteColor().isLight() // true
UIColor.blackColor().isLight() // false
Returns true
when the color's perceived brightness is dark.
UIColor.blackColor().isLight() // true
UIColor.whiteColor().isLight() // false
Returns a random color.
let color = UIColor.randomColor()
color.rgba() // (r: 67, g: 122, b: 134 a:255)
Felucia is released under the MIT license. See LICENSE for details.