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.deviceRGB
spaceDeclaration
Swift
public static let red: Color
-
Returns the green color in
PDFColorSpace.deviceRGB
spaceDeclaration
Swift
public static let green: Color
-
Returns the blue color in
PDFColorSpace.deviceRGB
spaceDeclaration
Swift
public static let blue: Color
-
Returns the black color in
PDFColorSpace.deviceGray
spaceDeclaration
Swift
public static let black: Color
-
Returns the white color in
PDFColorSpace.deviceGray
spaceDeclaration
Swift
public static let white: Color
-
Returns the transparent white color in
PDFColorSpace.deviceGray
spaceDeclaration
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
colorSpace
is.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
colorSpace
is.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
colorSpace
is.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
colorSpace
is.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
colorSpace
is.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
colorSpace
is.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
colorSpace
is.deviceCMYK
or.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
red
The red component of the color.
green
The green component of the color.
blue
The blue component of the color.
alpha
The alpha component of the color. Default value is 1.
Return Value
The color with the specified components, or
nil
if 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
cyan
The cyan component of the color.
magenta
The magenta component of the color.
yellow
The yellow component of the color.
black
The black component of the color.
alpha
The alpha component of the color. Default value is 1.
Return Value
The color with the specified components, or
nil
if 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
gray
The gray component of the color.
alpha
The alpha component of the color. Default value is 1.
Return Value
The color with the specified components, or
nil
if 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
colorSpace
The 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) -> Color
Parameters
colorSpace
The 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)