Module: HexaPDF::Content::ColorSpace
- Defined in:
- lib/hexapdf/content/color_space.rb
Overview
This module contains the color space implementations.
General Information
The PDF specification defines several color spaces. Probably the most used ones are the device color spaces DeviceRGB, DeviceCMYK and DeviceGray. However, there are several others. For example, patterns are also implemented via color spaces.
HexaPDF provides implementations for the most common color spaces. Additional ones can easily be added. After implementing one it just has to be registered on the global configuration object under the ‘color_space.map’ key.
Color space implementations are currently used so that different colors can be distinguished and to provide better error handling.
Color Space Implementations
A color space implementation consists of two classes: one for the color space and one for its colors.
The class for the color space needs to respond to the following methods:
- #initialize(definition)
-
Creates the color space using the given array with the color space definition. The first item in the array is always the color space family, the other items are color space specific.
- #family
-
Returns the PDF name of the color space family this color space belongs to.
- #definition
-
Returns the color space definition as array.
- #default_color
-
Returns the default color for this color space.
- #color(*args)
-
Returns the color corresponding to the given arguments. The number and types of the arguments differ from one color space to another.
The class representing a color in the color space needs to respond to the following methods:
- #color_space
-
Returns the associated color space object.
- #components
-
Returns an array of components that uniquely identifies this color within the color space.
See: PDF1.7 s8.6
Defined Under Namespace
Modules: ColorUtils Classes: DeviceCMYK, DeviceGray, DeviceRGB, Universal