Color
public struct Color : Equatable
A set of components that define a color. The color space is defined by the drawing context.
-
Red value
Declaration
Swift
public let red: Float
-
Green value
Declaration
Swift
public let green: Float
-
Blue value
Declaration
Swift
public let blue: Float
-
Alpha value
Declaration
Swift
public let alpha: Float
-
The grey value of the color, determined by averaging the channels.
Declaration
Swift
public var grey: Float { get }
-
Instantiate a new Color
/// This method expects color values between
0
and1
Declaration
Swift
public init(red: Float, green: Float, blue: Float, alpha: Float = 1)
Parameters
r
Red value
g
Green value
b
Blue value
a
Alpha value
-
Instantiate a new Color
This method expects color values between
0
and255
Declaration
Swift
public init(_ red: Int, _ green: Int, _ blue: Int, _ alpha: Float = 1)
Parameters
r
Red value
g
Green value
b
Blue value
a
Alpha value
-
Create a grey
Declaration
Swift
public init(grey: Float, _ alpha: Float = 1)
Parameters
grey
Decimal grey value
a
Alpha value, from 0 to 1
-
Create a color from a hex string From: https://stackoverflow.com/a/26341062
Declaration
Swift
public init(hexString: String, alpha: Float = 1)
-
Convert to a hex string From: https://stackoverflow.com/a/26341062
Declaration
Swift
public func toHex() -> String
-
Createa CGColor
Declaration
Swift
public func toCGColor() -> CGColor
-
Returns an RGBA string
Declaration
Swift
public func toRGBA() -> String
-
The color black
Declaration
Swift
public static var black: Color { get }
-
The color white
Declaration
Swift
public static var white: Color { get }
-
A clear color (black, with 0 alpha)
Declaration
Swift
public static var clear: Color { get }
-
The color red
Declaration
Swift
public static var red: Color { get }
-
The color green
Declaration
Swift
public static var green: Color { get }
-
The color blue
Declaration
Swift
public static var blue: Color { get }