##

Color Class Reference
Common

Defines a color. More...

`#include <common/common.hh>`

## Public Types

typedef unsigned int | ABGR
typedef unsigned int | ARGB
typedef unsigned int | BGRA
typedef unsigned int | RGBA

## Public Member Functions

| Color () GAZEBO_DEPRECATED(9.0)
| Constructor. More...
| Color (const Color &_clr) GAZEBO_DEPRECATED(9.0)
| Copy Constructor. More...
| Color (const ignition::math::Color &_color) GAZEBO_DEPRECATED(9.0)
| Converting constructor. More...
| Color (float _r, float _g, float _b, float _a=1.0) GAZEBO_DEPRECATED(9.0)
| Constructor. More...
virtual | ~Color () GAZEBO_DEPRECATED(9.0)
| Destructor. More...
ABGR | GetAsABGR () const
| Get as uint32 ABGR packed value. More...
ARGB | GetAsARGB () const
| Get as uint32 ARGB packed value. More...
BGRA | GetAsBGRA () const
| Get as uint32 BGRA packed value. More...
RGBA | GetAsRGBA () const
| Get as uint32 RGBA packed value. More...
ignition::math::Vector3d | HSV () const
| Get the color in HSV colorspace. More...
ignition::math::Color | Ign () const
| Convert to ignition type. More...
bool | operator!= (const Color &_pt) const
| Inequality operator. More...
const Color | operator* (const Color &_pt) const
| Multiplication operator. More...
const Color | operator* (const float &_v) const
| Multiply all color components by _v. More...
const Color & | operator*= (const Color &_pt)
| Multiplication equal operator. More...
Color | operator+ (const Color &_pt) const
| Addition operator (this + _pt) More...
Color | operator+ (const float &_v) const
| Add _v to all color components. More...
const Color & | operator+= (const Color &_pt)
| Addition equal operator. More...
Color | operator- (const Color &_pt) const
| Subtraction operator. More...
Color | operator- (const float &_v) const
| Subtract _v from all color components. More...
const Color & | operator-= (const Color &_pt)
| Subtraction equal operator. More...
const Color | operator/ (const Color &_pt) const
| Division operator. More...
const Color | operator/ (const float &_v) const
| Divide all color component by _v. More...
const Color & | operator/= (const Color &_pt)
| Division equal operator. More...
Color & | operator= (const Color &_pt) GAZEBO_DEPRECATED(9.0)
| Equal operator. More...
Color & | operator= (const ignition::math::Color &_color) GAZEBO_DEPRECATED(9.0)
| Converting assignment operator. More...
bool | operator== (const Color &_pt) const
| Equality operator. More...
float | operator[] (unsigned int _index)
| Array index operator. More...
void | Reset ()
| Reset the color to default values. More...
void | Set (float _r=1, float _g=1, float _b=1, float _a=1)
| Set the contents of the vector. More...
void | SetFromABGR (const ABGR _v)
| Set from uint32 ABGR packed value. More...
void | SetFromARGB (const ARGB _v)
| Set from uint32 ARGB packed value. More...
void | SetFromBGRA (const BGRA _v)
| Set from uint32 BGRA packed value. More...
void | SetFromHSV (float _h, float _s, float _v)
| Set a color based on HSV values. More...
void | SetFromRGBA (const RGBA _v)
| Set from uint32 RGBA packed value. More...
void | SetFromYUV (float _y, float _u, float _v)
| Set from yuv. More...
ignition::math::Vector3d | YUV () const
| Get the color in YUV colorspace. More...

## Public Attributes

float | a
float | b
float | g
float | r

## Static Public Attributes

static const Color | Black
| (0, 0, 0) More...
static const Color | Blue
| (0, 0, 1) More...
static const Color | Green
| (0, 1, 0) More...
static const Color | Magenta
| (1, 0, 1) More...
static const Color | Red
| (1, 0, 0) More...
static const Color | White
| (1, 1, 1) More...
static const Color | Yellow
| (1, 1, 0) More...

## Friends

std::ostream & | operator<< (std::ostream &_out, const Color &_pt)
| Stream insertion operator. More...
std::istream & | operator>> (std::istream &_in, Color &_pt)
| Stream insertion operator. More...

## Detailed Description

Defines a color.

## Member Typedef Documentation

## ABGR

typedef unsigned int ABGR

## ARGB

typedef unsigned int ARGB

## BGRA

typedef unsigned int BGRA

## RGBA

typedef unsigned int RGBA

## Constructor & Destructor Documentation

## Color() [1/4]

Color | ( |  | ) |

Constructor.

## Color() [2/4]

Color | ( | float | _r,
|  | float | _g,
|  | float | _b,
|  | float | _a = `1.0`
| ) |  |

Constructor.

Parameters

  [in] | _r | Red value (range 0 to 1)
  [in] | _g | Green value (range 0 to 1
  [in] | _b | Blue value (range 0 to 1
  [in] | _a | Alpha value (0=transparent, 1=opaque)

## Color() [3/4]

Color | ( | const ignition::math::Color & | _color | ) |

Converting constructor.

Parameters

  [in] | _color | Color class from ignition library

## Color() [4/4]

Color | ( | const Color & | _clr | ) |

Copy Constructor.

Parameters

  [in] | _clr | Color to copy

## ~Color()

virtual ~Color | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## GetAsABGR()

ABGR GetAsABGR | ( |  | ) | const

Get as uint32 ABGR packed value.

Returns
  the color

## GetAsARGB()

ARGB GetAsARGB | ( |  | ) | const

Get as uint32 ARGB packed value.

Returns
  the color

## GetAsBGRA()

BGRA GetAsBGRA | ( |  | ) | const

Get as uint32 BGRA packed value.

Returns
  the color

## GetAsRGBA()

RGBA GetAsRGBA | ( |  | ) | const

Get as uint32 RGBA packed value.

Returns
  the color

## HSV()

ignition::math::Vector3d HSV | ( |  | ) | const

Get the color in HSV colorspace.

Returns
  HSV values in an ignition::math::Vector3d format.

## Ign()

ignition::math::Color Ign | ( |  | ) | const

Convert to ignition type.

## operator!=()

bool operator!= | ( | const Color & | _pt | ) | const

Inequality operator.

Parameters

  [in] | _pt | The color to check for inequality

Returns
  True if the this color does not equal _pt

## operator*() [1/2]

const Color operator* | ( | const Color & | _pt | ) | const

Multiplication operator.

Parameters

  [in] | _pt | The color to muliply by

Returns
  The resulting color

## operator*() [2/2]

const Color operator* | ( | const float & | _v | ) | const

Multiply all color components by _v.

Parameters

  [in] | _v | The value to multiply by

Returns
  The resulting color

## operator*=()

const Color& operator*= | ( | const Color & | _pt | ) |

Multiplication equal operator.

Parameters

  [in] | _pt | The color to muliply by

Returns
  The resulting color

## operator+() [1/2]

Color operator+ | ( | const Color & | _pt | ) | const

Addition operator (this + _pt)

Parameters

  [in] | _pt | Color to add

Returns
  The resulting color

## operator+() [2/2]

Color operator+ | ( | const float & | _v | ) | const

Add _v to all color components.

Parameters

  [in] | _v | Value to add to each color component

Returns
  The resulting color

## operator+=()

const Color& operator+= | ( | const Color & | _pt | ) |

Addition equal operator.

Parameters

  [in] | _pt | Color to add

Returns
  The resulting color

## operator-() [1/2]

Color operator- | ( | const Color & | _pt | ) | const

Subtraction operator.

Parameters

  [in] | _pt | The color to substract

Returns
  The resulting color

## operator-() [2/2]

Color operator- | ( | const float & | _v | ) | const

Subtract _v from all color components.

Parameters

  [in] | _v | Value to subtract

Returns
  The resulting color

## operator-=()

const Color& operator-= | ( | const Color & | _pt | ) |

Subtraction equal operator.

Parameters

  [in] | _pt | Color to subtract

Returns
  The resulting color

## operator/() [1/2]

const Color operator/ | ( | const Color & | _pt | ) | const

Division operator.

Parameters

  [in] | _pt | Color to divide by

Returns
  The resulting color

## operator/() [2/2]

const Color operator/ | ( | const float & | _v | ) | const

Divide all color component by _v.

Parameters

  [in] | _v | The value to divide by

Returns
  The resulting color

## operator/=()

const Color& operator/= | ( | const Color & | _pt | ) |

Division equal operator.

Parameters

  [in] | _pt | Color to divide by

Returns
  The resulting color

## operator=() [1/2]

Color& operator= | ( | const Color & | _pt | ) |

Equal operator.

Parameters

  [in] | _pt | Color to copy

Returns
  Reference to this color

## operator=() [2/2]

Color& operator= | ( | const ignition::math::Color & | _color | ) |

Converting assignment operator.

Parameters

  [in] | _color | Color class from ignition library

## operator==()

bool operator== | ( | const Color & | _pt | ) | const

Equality operator.

Parameters

  [in] | _pt | The color to check for equality

Returns
  True if the this color equals _pt

## operator[]()

float operator[] | ( | unsigned int | _index | ) |

Array index operator.

Parameters

  [in] | _index | Color component index(0=red, 1=green, 2=blue)

Returns
  r, g, b, or a when _index is 0, 1, 2 or 3

## Reset()

void Reset | ( |  | ) |

Reset the color to default values.

## Set()

void Set | ( | float | _r = `1`,
|  | float | _g = `1`,
|  | float | _b = `1`,
|  | float | _a = `1`
| ) |  |

Set the contents of the vector.

Parameters

  [in] | _r | Red value (range 0 to 1)
  [in] | _g | Green value (range 0 to 1)
  [in] | _b | Blue value (range 0 to 1)
  [in] | _a | Alpha value (0=transparent, 1=opaque)

## SetFromABGR()

void SetFromABGR | ( | const ABGR | _v | ) |

Set from uint32 ABGR packed value.

Parameters

  [in] | _v | the new color

## SetFromARGB()

void SetFromARGB | ( | const ARGB | _v | ) |

Set from uint32 ARGB packed value.

Parameters

  [in] | _v | the new color

## SetFromBGRA()

void SetFromBGRA | ( | const BGRA | _v | ) |

Set from uint32 BGRA packed value.

Parameters

  [in] | _v | the new color

## SetFromHSV()

void SetFromHSV | ( | float | _h,
|  | float | _s,
|  | float | _v
| ) |  |

Set a color based on HSV values.

Parameters

  [in] | _h | Hue(0..360)
  [in] | _s | Saturation(0..1)
  [in] | _v | Value(0..1)

## SetFromRGBA()

void SetFromRGBA | ( | const RGBA | _v | ) |

Set from uint32 RGBA packed value.

Parameters

  [in] | _v | the new color

## SetFromYUV()

void SetFromYUV | ( | float | _y,
|  | float | _u,
|  | float | _v
| ) |  |

Set from yuv.

Parameters

  [in] | _y | value
  [in] | _u | value
  [in] | _v | value

## YUV()

ignition::math::Vector3d YUV | ( |  | ) | const

Get the color in YUV colorspace.

Returns
  The YUV color in an ignition::math::Vector3d format.

## Friends And Related Function Documentation

## operator<<

std::ostream& operator<< | ( | std::ostream & | _out,
|  | const Color & | _pt
| ) |  |

friend

Stream insertion operator.

Parameters

  [in] | _out | the output stream
  [in] | _pt | the color

Returns
  the output stream

## operator>>

std::istream& operator>> | ( | std::istream & | _in,
|  | Color & | _pt
| ) |  |

friend

Stream insertion operator.

Parameters

  [in] | _in | the input stream
  [in] | _pt |

## Member Data Documentation

## a

float a

## b

float b

## Black

const Color Black

static

(0, 0, 0)

## Blue

const Color Blue

static

(0, 0, 1)

## g

float g

## Green

const Color Green

static

(0, 1, 0)

## Magenta

const Color Magenta

static

(1, 0, 1)

## r

float r

## Red

const Color Red

static

(1, 0, 0)

## White

const Color White

static

(1, 1, 1)

## Yellow

const Color Yellow

static

(1, 1, 0)

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

- Color.hh