Color

open class Color : Hashable, Equatable

Represents a color. This class implements Equatable.

  • Initializes a new instance of the Color class with a default color.

    Declaration

    Swift

    public convenience init()

    Return Value

    The newly initialized Color object.

  • Initializes a new instance of the Color class with the specified RGB values.

    Declaration

    Swift

    public convenience init(red: Double, green: Double, blue: Double)

    Parameters

    red

    The red value.

    green

    The green value.

    blue

    The blue value.

    Return Value

    The newly initialized Color object.

  • Initializes a new instance of the Color class with the specified RGB values and alpha value.

    Declaration

    Swift

    public init(alpha: Double, red: Double, green: Double, blue: Double)

    Parameters

    alpha

    The alpha value.

    red

    The red value.

    green

    The green value.

    blue

    The blue value.

    Return Value

    The newly initialized Color object.

  • Initializes a new instance of the Color class with the specified RGB values and alpha value given as bytes.

    Declaration

    Swift

    open class func fromBytes(_ alpha: UInt8, red: UInt8, green: UInt8, blue: UInt8) -> Color

    Parameters

    alpha

    A 8-bit unsigned integer value that represents the alpha value.

    red

    A 8-bit unsigned integer value that represents the red value.

    green

    A 8-bit unsigned integer value that represents the green value.

    blue

    A 8-bit unsigned integer value that represents the blue value.

    Return Value

    The newly initialized Color object.

  • Initializes a new instance of the Color class with the specified RGB values.

    Declaration

    Swift

    open class func fromRGB(_ red: UInt8, green: UInt8, blue: UInt8) -> Color

    Parameters

    red

    A 8-bit unsigned integer value that represents the red value.

    green

    A 8-bit unsigned integer value that represents the green value.

    blue

    A 8-bit unsigned integer value that represents the blue value.

    Return Value

    The newly initialized Color object.

  • Initializes a new instance of the Color class from the specified string.

    Declaration

    Swift

    public class func fromString(_ s: String) -> Color

    Parameters

    s

    The string to parse.

    Return Value

    The newly initialized Color object.

  • Serializes this Color instance to a string.

    Declaration

    Swift

    open func toString() -> String

    Return Value

    A string that represents this Color.

  • Checks if this Color is empty.

    Declaration

    Swift

    open func isEmpty() -> Bool

    Return Value

    True if the Color is empty; otherwise false.

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • red

    Initializes the red value of this Color.

    Declaration

    Swift

    open var red: Double
  • Initializes the green value of this Color.

    Declaration

    Swift

    open var green: Double
  • Initializes the blue value of this Color.

    Declaration

    Swift

    open var blue: Double
  • Initializes the alpha value of this Color.

    Declaration

    Swift

    open var alpha: Double