Color

public typealias Color = UIKit.UIColor

Mechanica

Alias for NSColor.

  • Mechanica

    Returns the hexadecimal string representation of self in the sRGB space.

    Declaration

    Swift

    public final var hexString: String?
  • Mechanica

    Initializes and returns a random color object in the sRGB space.

    Declaration

    Swift

    public class func random(randomAlpha: Bool = false) -> Self
  • Mechanica

    Alias for RGBA color space components

    Declaration

    Swift

    public typealias RGBA = (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)
  • Mechanica

    Returns the color’s RGBA components as Ints.

    Declaration

    Swift

    public final var rgbaComponents: (red: Int, green: Int, blue: Int, alpha: Int)?
  • Mechanica

    Returns the color’s RGBA components as a tuple of CGFloat.

    Declaration

    Swift

    public final var rgba: RGBA?
  • Mechanica

    Creates a new color in the sRGB color space (if needed) guard letthat matches (or closely approximates) the current color. Although the new color might have different component values, it looks the same as the original.

    Declaration

    Swift

    public final func convertedToCompatibleSRGBColor() -> Color?
  • Mechanica

    Returns a sRGB color from a hexadecimal integer.

    Example:

    Color(hex: 0xFF0000)
    Color(hex: 0xFF0000, alpha: 0.5)
    

    Declaration

    Swift

    public convenience init(hex: UInt32, alpha: CGFloat = 1)
  • Mechanica

    Creates and returns an Color object given an hex color string.

    Note

    Supported formats: RGB, #RGB, RGBA, #RGBA, RRGGBB, #RRGGBB, RRGGBBAA, #RRGGBBAA).

    Declaration

    Swift

    public convenience init?(hexString: String)
  • Mechanica

    Alias for HSBA color space components

    Declaration

    Swift

    public typealias HSBA = (hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat)
  • Mechanica

    Returns the components that make up the color in the HSBA color space.

    Declaration

    Swift

    public final var hsba: HSBA?
  • Mechanica

    Blends two colors together.

    Note

    The sum of the two percentages must be 1.0 otherwise the blendind operation is not executed.

    Declaration

    Swift

    public static func blend(_ firstColor: Color, percentage firstPercentage: CGFloat = 0.5, with secondColor: Color, percentage secondPercentage: CGFloat = 0.5) -> Color?

    Return Value

    a new color blending the two colors.