RainbowColor

extension RainbowColor

Add heaxdecimal initialisation to RainbowColor

  • Parses the given 64 bits number, supporting 3, 4, 6 and 8 hexadecimal numbers.

    Supported formats:

    • 0x123
    • 0x123f
    • 0x112233
    • 0x112233cc

    If the given value is greater than 0xFFFFFFFF, nil is returned

    Declaration

    Swift

    public convenience init?(hex: UInt64)

    Parameters

    hex

    Alphanumeric RGBA color

  • Parses the given alphanumerical string, support 3, 4, 6 and 8 characters string, optionally prefixed by an hashtag.

    Supported formats:

    • #123
    • #123f
    • #112233
    • #112233cc

    If none of the formats fit, or the string contains an invalid character, nil is returned.

    Declaration

    Swift

    public convenience init?(hex: String)

    Parameters

    hex

    Alphanumeric RGBA color string

  • hex

    Returns the hexadecimal representation of the color.

    If the color has no alpha component, it will return a 6 letter string with a leading hash-tag, e.g. #123456. If the alpha component is set, it will return a 8 letter string with a leading hash-tag, e.g. #123456ab

    Declaration

    Swift

    public var hex: String { get }