StyleColor

public struct StyleColor : Codable, Equatable

Represents a color as defined by the Mapbox Style Spec

  • red

    A value from 0 to 255, as required by the Mapbox Style Spec

    Declaration

    Swift

    public let red: Double
  • A value from 0 to 255, as required by the Mapbox Style Spec

    Declaration

    Swift

    public let green: Double
  • A value from 0 to 255, as required by the Mapbox Style Spec

    Declaration

    Swift

    public let blue: Double
  • A value from 0 to 1, as required by the Mapbox Style Spec

    Declaration

    Swift

    public let alpha: Double
  • Creates a StyleColor from individually-provided color components. Returns nil if any of the channel values are out of the supported ranges.

    Declaration

    Swift

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

    Parameters

    red

    A value from 0 to 255, as required by the Mapbox Style Spec

    green

    A value from 0 to 255, as required by the Mapbox Style Spec

    blue

    A value from 0 to 255, as required by the Mapbox Style Spec

    alpha

    A value from 0 to 1, as required by the Mapbox Style Spec

  • Creates a StyleColor from a UIColor

    Declaration

    Swift

    public init(_ color: UIColor)

    Parameters

    color

    A UIColor in the sRGB color space

  • StyleColor can be decoded from an rgba expression or from an rgba color string

    Throws

    Throws if neither an rgba expression nor an rbga color string could be decoded.

    Declaration

    Swift

    public init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder from which the StyleColor will attempt to decode an rgba expression or rgba color string

  • StyleColor is always encoded to an rgba color string

    Throws

    Throws if the provided encoder does not allow encoding the rgba color string.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to which the rgba color string is encoded