Color
public struct Color : Hashable
This structure represents a color. Property values must be between 0 and 1.
Supported color spaces:
-
Returns the red color in
PDFColorSpace.deviceRGBspaceDeclaration
Swift
public static let red: Color -
Returns the green color in
PDFColorSpace.deviceRGBspaceDeclaration
Swift
public static let green: Color -
Returns the blue color in
PDFColorSpace.deviceRGBspaceDeclaration
Swift
public static let blue: Color -
Returns the black color in
PDFColorSpace.deviceGrayspaceDeclaration
Swift
public static let black: Color -
Returns the white color in
PDFColorSpace.deviceGrayspaceDeclaration
Swift
public static let white: Color -
Returns the transparent white color in
PDFColorSpace.deviceGrayspaceDeclaration
Swift
public static let clear: Color -
The color space associated with the color.
Declaration
Swift
public var colorSpace: PDFColorSpace { get } -
The value of the alpha component associated with the color.
Declaration
Swift
public var alpha: Float -
The direct value of the red component associated with the color if the
colorSpaceis.deviceRGB, or the computed value otherwise.Declaration
Swift
public var red: Float { get set } -
The direct value of the green component associated with the color if the
colorSpaceis.deviceRGB, or the computed value otherwise.Declaration
Swift
public var green: Float { get set } -
The direct value of the blue component associated with the color if the
colorSpaceis.deviceRGB, or the computed value otherwise.Declaration
Swift
public var blue: Float { get set } -
The direct value of the cyan component associated with the color if the
colorSpaceis.deviceCMYK, or the computed value otherwise.Declaration
Swift
public var cyan: Float { get set } -
The direct value of the magenta component associated with the color if the
colorSpaceis.deviceCMYK, or the computed value otherwise.Declaration
Swift
public var magenta: Float { get set } -
The direct value of the yellow component associated with the color if the
colorSpaceis.deviceCMYK, or the computed value otherwise.Declaration
Swift
public var yellow: Float { get set } -
The direct value of the black component associated with the color if the
colorSpaceis.deviceCMYKor.deviceGray, or the computed value otherwise.Declaration
Swift
public var black: Float { get set } -
Creates a color with the RGB color model.
For each parameter valid values are between 0 and 1.
Declaration
Swift
public init?(red: Float, green: Float, blue: Float, alpha: Float = 1)Parameters
redThe red component of the color.
greenThe green component of the color.
blueThe blue component of the color.
alphaThe alpha component of the color. Default value is 1.
Return Value
The color with the specified components, or
nilif the values specified were invalid. -
Creates a color with the CMYK color model.
For each parameter valid values are between 0 and 1.
Declaration
Swift
public init?(cyan: Float, magenta: Float, yellow: Float, black: Float, alpha: Float = 1)Parameters
cyanThe cyan component of the color.
magentaThe magenta component of the color.
yellowThe yellow component of the color.
blackThe black component of the color.
alphaThe alpha component of the color. Default value is 1.
Return Value
The color with the specified components, or
nilif the values specified were invalid. -
Creates a color with the gray shades color model.
For each parameter valid values are between 0 and 1.
Declaration
Swift
public init?(gray: Float, alpha: Float = 1)Parameters
grayThe gray component of the color.
alphaThe alpha component of the color. Default value is 1.
Return Value
The color with the specified components, or
nilif the values specified were invalid. -
Converts the color to the specified color space.
Supported color spaces:
Declaration
Swift
public mutating func convert(to colorSpace: PDFColorSpace)Parameters
colorSpaceThe color space to convert the color to.
-
Creates a new color by converting the current color to the specified color space.
Supported color spaces:
Declaration
Swift
@inlinable public func converting(to colorSpace: PDFColorSpace) -> ColorParameters
colorSpaceThe color space of the new color.
Return Value
The new color with the specified color space.
-
Declaration
Swift
public var debugDescription: String { get }
-
Declaration
Swift
public init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float)
View on GitHub
Color Structure Reference