Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color Class Reference

Defines a color using a red (R), green (G), blue (B), and alpha (A) component. More...

#include <ignition/math/Color.hh>

Public Types

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

Public Member Functions

 Color ()
 Constructor. More...
 
 Color (const float _r, const float _g, const float _b, const float _a=1.0)
 Constructor. More...
 
 Color (const Color &_clr)
 Copy Constructor. More...
 
virtual ~Color ()
 Destructor. More...
 
float A () const
 Get the alpha value. More...
 
float & A ()
 Get a mutable reference to the alpha value. More...
 
void A (const float _a)
 Set the alpha value. More...
 
ABGR AsABGR () const
 Get as uint32 ABGR packed value. More...
 
ARGB AsARGB () const
 Get as uint32 ARGB packed value. More...
 
BGRA AsBGRA () const
 Get as uint32 BGRA packed value. More...
 
RGBA AsRGBA () const
 Get as uint32 RGBA packed value. More...
 
float B () const
 Get the blue value. More...
 
float & B ()
 Get a mutable reference to the blue value. More...
 
void B (const float _b)
 Set the blue value. More...
 
float G () const
 Get the green value. More...
 
float & G ()
 Get a mutable reference to the green value. More...
 
void G (const float _g)
 Set the green value. More...
 
Vector3f HSV () const
 Get the color in HSV colorspace. 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 Coloroperator *= (const Color &_pt)
 Multiplication equal operator. More...
 
bool operator!= (const Color &_pt) const
 Inequality 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 Coloroperator+= (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 Coloroperator-= (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 Coloroperator/= (const Color &_pt)
 Division equal operator. More...
 
Coloroperator= (const Color &_pt)
 Equal operator. More...
 
bool operator== (const Color &_pt) const
 Equality operator. More...
 
float operator[] (const unsigned int _index)
 Array index operator. More...
 
float R () const
 Get the red value. More...
 
float & R ()
 Get a mutable reference to the red value. More...
 
void R (const float _r)
 Set the red value. More...
 
void Reset ()
 Reset the color to default values to red=0, green=0, blue=0, alpha=1. More...
 
void Set (const float _r=1, const float _g=1, const float _b=1, const 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 (const float _h, const float _s, const float _v)
 Set a color based on HSV values. More...
 
void SetFromRGBA (const RGBA _v)
 Set from uint32 RGBA packed value. More...
 
void SetFromYUV (const float _y, const float _u, const float _v)
 Set from yuv. More...
 
Vector3f YUV () const
 Get the color in YUV colorspace. More...
 

Static Public Attributes

static const Color Black
 (0, 0, 0) More...
 
static const Color Blue
 (0, 0, 1) More...
 
static const Color Cyan
 (0, 1, 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 using a red (R), green (G), blue (B), and alpha (A) component.

Each color component is in the range [0..1].

Member Typedef Documentation

◆ ABGR

◆ ARGB

◆ BGRA

◆ RGBA

Constructor & Destructor Documentation

◆ Color() [1/3]

ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Color ( )

Constructor.

◆ Color() [2/3]

ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Color ( const float  _r,
const float  _g,
const float  _b,
const float  _a = 1.0 
)

Constructor.

Parameters
[in]_rRed value (range 0 to 1)
[in]_gGreen value (range 0 to 1
[in]_bBlue value (range 0 to 1
[in]_aAlpha value (0=transparent, 1=opaque)

◆ Color() [3/3]

ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Color ( const Color _clr)

Copy Constructor.

Parameters
[in]_clrColor to copy

◆ ~Color()

virtual ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::~Color ( )
virtual

Destructor.

Member Function Documentation

◆ A() [1/3]

float ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::A ( ) const

Get the alpha value.

Returns
The alpha value

◆ A() [2/3]

float& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::A ( )

Get a mutable reference to the alpha value.

Returns
The alpha value

◆ A() [3/3]

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::A ( const float  _a)

Set the alpha value.

Parameters
_rNew alpha value

◆ AsABGR()

ABGR ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::AsABGR ( ) const

Get as uint32 ABGR packed value.

Returns
the color

◆ AsARGB()

ARGB ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::AsARGB ( ) const

Get as uint32 ARGB packed value.

Returns
the color

◆ AsBGRA()

BGRA ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::AsBGRA ( ) const

Get as uint32 BGRA packed value.

Returns
the color

◆ AsRGBA()

RGBA ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::AsRGBA ( ) const

Get as uint32 RGBA packed value.

Returns
the color

◆ B() [1/3]

float ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::B ( ) const

Get the blue value.

Returns
The blue value

◆ B() [2/3]

float& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::B ( )

Get a mutable reference to the blue value.

Returns
The blue value

◆ B() [3/3]

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::B ( const float  _b)

Set the blue value.

Parameters
_rNew blue value

◆ G() [1/3]

float ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::G ( ) const

Get the green value.

Returns
The green value

◆ G() [2/3]

float& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::G ( )

Get a mutable reference to the green value.

Returns
The green value

◆ G() [3/3]

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::G ( const float  _g)

Set the green value.

Parameters
_rNew green value

◆ HSV()

Vector3f ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::HSV ( ) const

Get the color in HSV colorspace.

Returns
HSV values in a Vector3f format. A vector3f containing {NAN_F, NAN_F, NAN_F} is returned on error.

◆ operator *() [1/2]

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator * ( const Color _pt) const

Multiplication operator.

Parameters
[in]_ptThe color to muliply by
Returns
The resulting color

◆ operator *() [2/2]

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator * ( const float &  _v) const

Multiply all color components by _v.

Parameters
[in]_vThe value to multiply by
Returns
The resulting color

◆ operator *=()

const Color& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator *= ( const Color _pt)

Multiplication equal operator.

Parameters
[in]_ptThe color to muliply by
Returns
The resulting color

◆ operator!=()

bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator!= ( const Color _pt) const

Inequality operator.

Parameters
[in]_ptThe color to check for inequality
Returns
True if the this color does not equal _pt

◆ operator+() [1/2]

Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator+ ( const Color _pt) const

Addition operator (this + _pt)

Parameters
[in]_ptColor to add
Returns
The resulting color

◆ operator+() [2/2]

Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator+ ( const float &  _v) const

Add _v to all color components.

Parameters
[in]_vValue to add to each color component
Returns
The resulting color

◆ operator+=()

const Color& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator+= ( const Color _pt)

Addition equal operator.

Parameters
[in]_ptColor to add
Returns
The resulting color

◆ operator-() [1/2]

Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator- ( const Color _pt) const

Subtraction operator.

Parameters
[in]_ptThe color to substract
Returns
The resulting color

◆ operator-() [2/2]

Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator- ( const float &  _v) const

Subtract _v from all color components.

Parameters
[in]_vValue to subtract
Returns
The resulting color

◆ operator-=()

const Color& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator-= ( const Color _pt)

Subtraction equal operator.

Parameters
[in]_ptColor to subtract
Returns
The resulting color

◆ operator/() [1/2]

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator/ ( const Color _pt) const

Division operator.

Parameters
[in]_ptColor to divide by
Returns
The resulting color

◆ operator/() [2/2]

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator/ ( const float &  _v) const

Divide all color component by _v.

Parameters
[in]_vThe value to divide by
Returns
The resulting color

◆ operator/=()

const Color& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator/= ( const Color _pt)

Division equal operator.

Parameters
[in]_ptColor to divide by
Returns
The resulting color

◆ operator=()

Color& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator= ( const Color _pt)

Equal operator.

Parameters
[in]_ptColor to copy
Returns
Reference to this color

◆ operator==()

bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator== ( const Color _pt) const

Equality operator.

Parameters
[in]_ptThe color to check for equality
Returns
True if the this color equals _pt

◆ operator[]()

float ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::operator[] ( const unsigned int  _index)

Array index operator.

Parameters
[in]_indexColor component index(0=red, 1=green, 2=blue)
Returns
r, g, b, or a when _index is 0, 1, 2 or 3. A NAN_F value is returned if the _index is invalid

◆ R() [1/3]

float ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::R ( ) const

Get the red value.

Returns
The red value

◆ R() [2/3]

float& ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::R ( )

Get a mutable reference to the red value.

Returns
The red value

◆ R() [3/3]

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::R ( const float  _r)

Set the red value.

Parameters
_rNew red value

◆ Reset()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Reset ( )

Reset the color to default values to red=0, green=0, blue=0, alpha=1.

◆ Set()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Set ( const float  _r = 1,
const float  _g = 1,
const float  _b = 1,
const float  _a = 1 
)

Set the contents of the vector.

Parameters
[in]_rRed value (range 0 to 1)
[in]_gGreen value (range 0 to 1)
[in]_bBlue value (range 0 to 1)
[in]_aAlpha value (0=transparent, 1=opaque)

◆ SetFromABGR()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::SetFromABGR ( const ABGR  _v)

Set from uint32 ABGR packed value.

Parameters
[in]_vthe new color

◆ SetFromARGB()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::SetFromARGB ( const ARGB  _v)

Set from uint32 ARGB packed value.

Parameters
[in]_vthe new color

◆ SetFromBGRA()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::SetFromBGRA ( const BGRA  _v)

Set from uint32 BGRA packed value.

Parameters
[in]_vthe new color

◆ SetFromHSV()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::SetFromHSV ( const float  _h,
const float  _s,
const float  _v 
)

Set a color based on HSV values.

Parameters
[in]_hHue(0..360)
[in]_sSaturation(0..1)
[in]_vValue(0..1)

◆ SetFromRGBA()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::SetFromRGBA ( const RGBA  _v)

Set from uint32 RGBA packed value.

Parameters
[in]_vthe new color

◆ SetFromYUV()

void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::SetFromYUV ( const float  _y,
const float  _u,
const float  _v 
)

Set from yuv.

Parameters
[in]_yvalue
[in]_uvalue
[in]_vvalue

◆ YUV()

Vector3f ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::YUV ( ) const

Get the color in YUV colorspace.

Returns
the YUV color

Friends And Related Function Documentation

◆ operator<<

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

Stream insertion operator.

Parameters
[in]_outthe output stream
[in]_ptthe color
Returns
the output stream

◆ operator>>

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

Stream insertion operator.

Parameters
[in]_inthe input stream
[in]_pt

Member Data Documentation

◆ Black

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Black
static

(0, 0, 0)

◆ Blue

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Blue
static

(0, 0, 1)

◆ Cyan

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Cyan
static

(0, 1, 1)

◆ Green

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Green
static

(0, 1, 0)

◆ Magenta

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Magenta
static

(1, 0, 1)

◆ Red

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Red
static

(1, 0, 0)

◆ White

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::White
static

(1, 1, 1)

◆ Yellow

const Color ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Color::Yellow
static

(1, 1, 0)


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