# Color Class

> A color specified by values appropriate for its color space.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.2.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Color
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/llms.txt

```cpp
class Color
```

**Namespace:** `datalogics_interface`

## Description

The values that are offered range from 0 to 1.0 for red, green, and blue (RGB) or cyan, magenta, yellow, and black (CYMK).

**Referenced by:** [`Annotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Annotation.md), [`Bookmark`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Bookmark.md), [`CircleAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/CircleAnnotation.md), [`FreeTextAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/FreeTextAnnotation.md), [`GraphicState`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/GraphicState.md), [`HighlightAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/HighlightAnnotation.md), [`InkAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/InkAnnotation.md), [`LineAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/LineAnnotation.md), [`LinkAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/LinkAnnotation.md), [`PolyLineAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/PolyLineAnnotation.md), [`PolygonAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/PolygonAnnotation.md), [`Redaction`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Redaction.md), [`SquareAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/SquareAnnotation.md), [`Style`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Style.md), [`TextMarkupAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/TextMarkupAnnotation.md), [`UnderlineAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/UnderlineAnnotation.md), [`WatermarkTextParams`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/WatermarkTextParams.md)

**Uses types:** [`ColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/ColorSpace.md)

## Constructors

### Color

```cpp
datalogics_interface::Color::Color(Color &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`Color &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Color.md))

### Color

```cpp
datalogics_interface::Color::Color(const class Pattern &pattern)
```

*constructor*

**Parameters**

- `pattern` ([`const class Pattern &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Pattern.md)): the grayscale color value for the new color (0.0 - 1.0)

Create a new color in the DeviceGray colorspace with the specified value.

### Color

```cpp
datalogics_interface::Color::Color(const ColorSpace &color_space, const std::vector< double > &values)
```

*constructor*

**Parameters**

- `color_space` ([`const ColorSpace &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/ColorSpace.md)): the grayscale color value for the new color (0.0 - 1.0)
- `values` (`const std::vector< double > &`)

Create a new color in the DeviceGray colorspace with the specified value.

### Color

```cpp
datalogics_interface::Color::Color(double c, double m, double y, double k)
```

*constructor*

**Parameters**

- `c` (`double`): the grayscale color value for the new color (0.0 - 1.0)
- `m` (`double`)
- `y` (`double`)
- `k` (`double`)

Create a new color in the DeviceGray colorspace with the specified value.

### Color

```cpp
datalogics_interface::Color::Color(double grey)
```

*constructor*

**Parameters**

- `grey` (`double`): the grayscale color value for the new color (0.0 - 1.0)

Create a new color in the DeviceGray colorspace with the specified value.

### Color

```cpp
datalogics_interface::Color::Color(double r, double g, double b)
```

*constructor*

**Parameters**

- `r` (`double`): the grayscale color value for the new color (0.0 - 1.0)
- `g` (`double`)
- `b` (`double`)

Create a new color in the DeviceGray colorspace with the specified value.

### ~Color

```cpp
datalogics_interface::Color::~Color()
```

*destructor*

## Methods

### get_space

```cpp
std::unique_ptr< ColorSpace > datalogics_interface::Color::get_space() const
```

**Returns:** [`std::unique_ptr< ColorSpace >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/ColorSpace.md)

The ColorSpace that this color belongs to.

The color space of the color.

### get_value

```cpp
std::vector< double > datalogics_interface::Color::get_value() const
```

**Returns:** `std::vector< double >`

A list of color component values, each ranging from 0.0 to 1.0.

The values of the color. Not valid for pattern-based colors.

### operator!=

```cpp
bool datalogics_interface::Color::operator!=(const Color &other) const
```

**Parameters**

- `other` ([`const Color &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Color.md))

**Returns:** `bool`

true if `other` is not equal to this.

Inequality.

### operator=

```cpp
Color & datalogics_interface::Color::operator=(Color &&) noexcept
```

**Parameters**

- (unnamed) ([`Color &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Color.md))

**Returns:** [`Color &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Color.md)

### operator==

```cpp
bool datalogics_interface::Color::operator==(const Color &other) const
```

**Parameters**

- `other` ([`const Color &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Color.md)): The Color to compare with.

**Returns:** `bool`

true if the two colors are equal, false otherwise.

Two Colors are considered equal if they have the same color space and the same component values.

### to_string

```cpp
std::string datalogics_interface::Color::to_string() const
```

**Returns:** `std::string`

A string describing the color, including its color space and component values.

Returns a string representation of this Color.
