Skip to content

Latest commit

 

History

History
54 lines (31 loc) · 1.3 KB

ColorSpace.md

File metadata and controls

54 lines (31 loc) · 1.3 KB

Introduction

A structure represents a color space.

Usage

Define a RGB ColorSpace

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 ColorSpace

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)

Predefined ColorSpace

Here are also some of predefined color spaces.

let adobeRGB = ColorSpace.adobeRGB
let sRGB = ColorSpace.sRGB
let displayP3 = ColorSpace.displayP3