StyleColor
public struct StyleColor : Codable, Equatable, RawRepresentable, ExpressibleByStringInterpolation
Represents a color as defined by the Mapbox Style Spec
-
A color string as defined by the Mapbox Style Spec.
Declaration
Swift
public let rawValue: String
-
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)
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
-
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 individually-provided color components. Returns nil if any of the channel values are out of the supported ranges.Declaration
Swift
public init?(hue: Double, saturation: Double, lightness: Double)
Parameters
hue
A value from 0 to 360, as required by the Mapbox Style Spec
saturation
A value from 0 to 100, as required by the Mapbox Style Spec
lightness
A value from 0 to 100, as required by the Mapbox Style Spec
-
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?(hue: Double, saturation: Double, lightness: Double, alpha: Double)
Parameters
hue
A value from 0 to 360, as required by the Mapbox Style Spec
saturation
A value from 0 to 100, as required by the Mapbox Style Spec
lightness
A value from 0 to 100, 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 aUIColor
Declaration
Swift
public init(_ color: UIColor)
Parameters
color
A
UIColor
in the sRGB color space
-
Creates a
StyleColor
from a color string as defined in the Mapbox Style Spec.Declaration
Swift
public init(rawValue: String)
Parameters
rawValue
A color string.
-
Declaration
Swift
public init(stringLiteral value: StringLiteralType)
-
StyleColor
can be decoded from an rgba expression or from an rgba color stringThrows
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 stringThrows
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