A structure represents a color space.
To define a RGB color space, it's have to provide the XYZ coordinates of white, red, green and blue.
let rgb = ColorSpace.calibratedRGB(white: Point(x: 0.3127, y: 0.3290),
red: Point(x: 0.6400, y: 0.3300),
green: Point(x: 0.3000, y: 0.6000),
blue: Point(x: 0.1500, y: 0.0600))
You can also specify the gamma values for each primary colors.
let rgb = ColorSpace.calibratedRGB(white: Point(x: 0.3127, y: 0.3290),
red: Point(x: 0.6400, y: 0.3300),
green: Point(x: 0.3000, y: 0.6000),
blue: Point(x: 0.1500, y: 0.0600),
gamma: (2.19921875, 2.19921875, 2.19921875))
Define a grayscale color space is same way as RGB color space.
let gray = ColorSpace.calibratedGray(white: Point(x: 0.3127, y: 0.3290), gamma: 2.19921875)
Here are also some of predefined color spaces.
let adobeRGB = ColorSpace.adobeRGB
let sRGB = ColorSpace.sRGB
let displayP3 = ColorSpace.displayP3