ome-xml 5.2.3

Public Types | Public Member Functions | Private Attributes | List of all members
ome::xml::model::primitives::Color Class Reference

An RGBA color value. More...

`#include <ome/xml/model/primitives/Color.h>`

## Public Types
typedef uint8_t | component_type
| The type of an individual color component (R, G, B, A).
typedef uint32_t | composed_type
| The type of all components composed as a single RGBA value (unsigned).
typedef int32_t | signed_type
| The type of all components composed as a single RGBA value (signed).

## Public Member Functions
| Color ()
| Construct a Color. More...
| Color (composed_type value)
| Construct a Color from an unsigned integer value. More...
| Color (signed_type value)
| Construct a Color from a signed integer value. More...
| Color (component_type r, component_type g, component_type b, component_type a=std::numeric_limits< component_type >::max())
| Construct a Color from separate red, green, blue and alpha components. More...
| Color (const std::string &str, bool sign=true)
| Construct a Color from a string. More...
component_type | getRed () const
| Get the red component of this color. More...
void | setRed (component_type red)
| Set the red component of this color. More...
component_type | getGreen () const
| Get the green component of this color. More...
void | setGreen (component_type green)
| Set the green component of this color. More...
component_type | getBlue () const
| Get the blue component of this color. More...
void | setBlue (component_type blue)
| Set the blue component of this color. More...
component_type | getAlpha () const
| Get the alpha component of this color. More...
void | setAlpha (component_type alpha)
| Set the alpha component of this color. More...
signed_type | getValue () const
| Get the signed integer value of this color. More...
void | setValue (composed_type value)
| Set the integer value of this color from an unsigned integer. More...
void | setValue (signed_type value)
| Set the integer value of this color from a signed integer. More...
| operator composed_type () const
| Cast the color to its value as an unsigned integer. More...
| operator signed_type () const
| Cast the color to its value as a signed integer. More...

## Private Attributes
composed_type | value
| The color value.

## Detailed Description

An RGBA color value.

Internally, this is representated as an unsigned integer comprised of the red, green, blue and alpha components. Externally, it may be constructed from a signed or unsigned integer, or all of the separate components. For compatibility reasons, it will default to input and output of a signed integer as its external string representation.

Do not inherit this primitive type; it intentionally does not have a virtual destructor.

Todo:
  : The use of a signed integer is not a good design. Look at correcting the model to use an unsigned type.

## Constructor & Destructor Documentation

## § Color() [1/5]

ome::xml::model::primitives::Color::Color | ( |  | ) |
| inline

Construct a Color.

Defaults to 0x000000FF (black).

Referenced by Color().

Here is the caller graph for this function:

## § Color() [2/5]

ome::xml::model::primitives::Color::Color | ( | composed_type | value | ) |
| inline

Construct a Color from an unsigned integer value.

Parameters

  value | the color value.

## § Color() [3/5]

ome::xml::model::primitives::Color::Color | ( | signed_type | value | ) |
| inline

Construct a Color from a signed integer value.

Parameters

  value | the color value.

## § Color() [4/5]

ome::xml::model::primitives::Color::Color | ( | component_type | r,
|  | component_type | g,
|  | component_type | b,
|  | component_type | a = `std::numeric_limits<component_type>::max()`
| ) |  |
| inline

Construct a Color from separate red, green, blue and alpha components.

Parameters

  r | the red component.
  g | the green component.
  b | the blue component.
  a | the alpha component.

References Color().

## § Color() [5/5]

ome::xml::model::primitives::Color::Color | ( | const std::string & | str,
|  | bool | sign = `true`
| ) |  |

Construct a Color from a string.

By default, the string contains an signed integer, thoguh this can be changed to unsigned.

Parameters

  str | The string to be parsed.
  sign | true if a signed integer, false if an unsigned integer

Exceptions

  std::invalid_argument | if the string is invalid.

References value.

## Member Function Documentation

## § getAlpha()

component_type ome::xml::model::primitives::Color::getAlpha | ( |  | ) | const
| inline

Get the alpha component of this color.

Returns
  the alpha component.

References value.

## § getBlue()

component_type ome::xml::model::primitives::Color::getBlue | ( |  | ) | const
| inline

Get the blue component of this color.

Returns
  the blue component.

References value.

## § getGreen()

component_type ome::xml::model::primitives::Color::getGreen | ( |  | ) | const
| inline

Get the green component of this color.

Returns
  the green component.

References value.

## § getRed()

component_type ome::xml::model::primitives::Color::getRed | ( |  | ) | const
| inline

Get the red component of this color.

Returns
  the red component.

References value.

## § getValue()

signed_type ome::xml::model::primitives::Color::getValue | ( |  | ) | const
| inline

Get the signed integer value of this color.

Returns
  the value.

References value.

## § operator composed_type()

ome::xml::model::primitives::Color::operator composed_type | ( |  | ) | const
| inline

Cast the color to its value as an unsigned integer.

Returns
  the color value.

References value.

## § operator signed_type()

ome::xml::model::primitives::Color::operator signed_type | ( |  | ) | const
| inline

Cast the color to its value as a signed integer.

Returns
  the color value.

References value.

## § setAlpha()

void ome::xml::model::primitives::Color::setAlpha | ( | component_type | alpha | ) |
| inline

Set the alpha component of this color.

Parameters

  alpha | the value of the alpha component.

References value.

## § setBlue()

void ome::xml::model::primitives::Color::setBlue | ( | component_type | blue | ) |
| inline

Set the blue component of this color.

Parameters

  blue | the value of the blue component.

References value.

## § setGreen()

void ome::xml::model::primitives::Color::setGreen | ( | component_type | green | ) |
| inline

Set the green component of this color.

Parameters

  green | the value of the green component.

References value.

## § setRed()

void ome::xml::model::primitives::Color::setRed | ( | component_type | red | ) |
| inline

Set the red component of this color.

Parameters

  red | the value of the red component.

References value.

## § setValue() [1/2]

void ome::xml::model::primitives::Color::setValue | ( | composed_type | value | ) |
| inline

Set the integer value of this color from an unsigned integer.

Parameters

  value | the value to set.

References value.

Referenced by ome::xml::model::primitives::operator>>().

Here is the caller graph for this function:

## § setValue() [2/2]

void ome::xml::model::primitives::Color::setValue | ( | signed_type | value | ) |
| inline

Set the integer value of this color from a signed integer.

Parameters

  value | the value to set.

References value.

The documentation for this class was generated from the following files:

- ome/xml/model/primitives/Color.h
- ome/xml/model/primitives/Color.cpp