Thea
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ColorRgba Class Reference

A color with four floating-point channels: red, green and blue, each in [0, 1]. More...

#include <ColorRgba.hpp>

Public Types

typedef Real value_type
 The numerical type of each channel. More...
 

Public Member Functions

Real a () const
 The value of the alpha channel. More...
 
Real & a ()
 A reference to the alpha channel. More...
 
Real b () const
 The value of the blue channel. More...
 
Real & b ()
 A reference to the blue channel. More...
 
ColorRgba bgra () const
 Swap the red and blue channels. More...
 
 ColorRgba ()
 Default constructor. More...
 
 ColorRgba (Real r_, Real g_, Real b_, Real a_=1)
 Construct from red, green, blue and alpha components. More...
 
 ColorRgba (ColorRgb const &rgb_, Real a_=1)
 Construct from an RGB color and an alpha component. More...
 
 ColorRgba (Vector4 const &v)
 Construct a color from a 4-vector. More...
 
 ColorRgba (Real const *v)
 Construct a color from four components in an array. More...
 
 ColorRgba (ColorRgba8 const &src)
 Construct from a color with 4 byte channels, with automatic scaling from [0, 255] to [0, 1]. More...
 
 ColorRgba (ColorRgb8 const &src)
 Construct from a color with 3 byte channels, with automatic scaling from [0, 255] to [0, 1]. More...
 
Real const * data () const
 Get the address of the array storing color channel values in RGBA order. More...
 
Real * data ()
 Get the address of the array storing color channel values in RGBA order. More...
 
void fill (Real v)
 Set all channels to the same value. More...
 
bool fuzzyEq (ColorRgba const &other) const
 Check if two colors are approximately equal. More...
 
bool fuzzyNe (ColorRgba const &other) const
 Check if two colors are not approximately equal. More...
 
Real g () const
 The value of the green channel. More...
 
Real & g ()
 A reference to the green channel. More...
 
ColorRgba operator* (Real s) const
 Multiplication by a scalar. More...
 
ColorRgba operator* (ColorRgba const &rhs) const
 Component-wise multiplication by another color. More...
 
ColorRgbaoperator*= (ColorRgba const &rhs)
 Multiply component-wise and assign. More...
 
ColorRgbaoperator*= (Real s)
 Multiply by a scalar and assign. More...
 
ColorRgba operator+ (ColorRgba const &rhs) const
 Addition. More...
 
ColorRgbaoperator+= (ColorRgba const &rhs)
 Add and assign. More...
 
ColorRgba operator- (ColorRgba const &rhs) const
 Subtraction. More...
 
ColorRgba operator- () const
 Negation of the color. More...
 
ColorRgbaoperator-= (ColorRgba const &rhs)
 Subtract and assign. More...
 
ColorRgba operator/ (Real s) const
 Division by a scalar. More...
 
ColorRgba operator/ (ColorRgba const &rhs) const
 Component-wise division by another color. More...
 
ColorRgbaoperator/= (ColorRgba const &rhs)
 Divide component-wise and assign. More...
 
ColorRgbaoperator/= (Real s)
 Divide by a scalar and assign. More...
 
template<typename IntegerT >
Real const & operator[] (IntegerT channel) const
 Array-style channel access. More...
 
template<typename IntegerT >
Real & operator[] (IntegerT channel)
 Array-style channel access. More...
 
Real r () const
 The value of the red channel. More...
 
Real & r ()
 A reference to the red channel. More...
 
ColorRgb rgb () const
 Get the red, green and blue channels as a ColorRgb. More...
 
void set (Real r_, Real g_, Real b_, Real a_)
 Set all channels simultaneously. More...
 
std::string toString () const
 Get a string representation of the color. More...
 

Static Public Member Functions

static ColorRgba const & black ()
 Opaque black color. More...
 
static ColorRgba const & blue ()
 Opaque blue color. More...
 
static ColorRgba const & brown ()
 Opaque brown color. More...
 
static ColorRgba const & cyan ()
 Opaque cyan color. More...
 
static ColorRgba fromARGB (uint32 argb)
 Initialize from an HTML-style color (e.g. More...
 
static ColorRgba const & gray ()
 Opaque gray color. More...
 
static ColorRgba const & green ()
 Opaque green color. More...
 
static ColorRgba const & orange ()
 Opaque orange color. More...
 
static ColorRgba const & purple ()
 Opaque purple color. More...
 
static ColorRgba const & red ()
 Opaque red color. More...
 
static ColorRgba const & white ()
 Opaque white color. More...
 
static ColorRgba const & yellow ()
 Opaque yellow color. More...
 
static ColorRgba const & zero ()
 Color with all channels zero (transparent black). More...
 

Detailed Description

A color with four floating-point channels: red, green and blue, each in [0, 1].

Derived from the G3D library: http://g3d.sourceforge.net

Definition at line 52 of file ColorRgba.hpp.

Member Typedef Documentation

typedef Real value_type

The numerical type of each channel.

Definition at line 58 of file ColorRgba.hpp.

Constructor & Destructor Documentation

ColorRgba ( )

Default constructor.

Does not initialize fields.

Definition at line 61 of file ColorRgba.hpp.

ColorRgba ( Real  r_,
Real  g_,
Real  b_,
Real  a_ = 1 
)

Construct from red, green, blue and alpha components.

Definition at line 64 of file ColorRgba.hpp.

ColorRgba ( ColorRgb const &  rgb_,
Real  a_ = 1 
)

Construct from an RGB color and an alpha component.

Definition at line 67 of file ColorRgba.hpp.

ColorRgba ( Vector4 const &  v)
explicit

Construct a color from a 4-vector.

Definition at line 70 of file ColorRgba.hpp.

ColorRgba ( Real const *  v)
explicit

Construct a color from four components in an array.

Definition at line 73 of file ColorRgba.hpp.

ColorRgba ( ColorRgba8 const &  src)

Construct from a color with 4 byte channels, with automatic scaling from [0, 255] to [0, 1].

Definition at line 56 of file ColorRgba.cpp.

ColorRgba ( ColorRgb8 const &  src)

Construct from a color with 3 byte channels, with automatic scaling from [0, 255] to [0, 1].

Definition at line 64 of file ColorRgba.cpp.

Member Function Documentation

Real a ( ) const

The value of the alpha channel.

Definition at line 103 of file ColorRgba.hpp.

Real& a ( )

A reference to the alpha channel.

Definition at line 106 of file ColorRgba.hpp.

Real b ( ) const

The value of the blue channel.

Definition at line 97 of file ColorRgba.hpp.

Real& b ( )

A reference to the blue channel.

Definition at line 100 of file ColorRgba.hpp.

ColorRgba bgra ( ) const

Swap the red and blue channels.

Definition at line 258 of file ColorRgba.hpp.

ColorRgba const & black ( )
static

Opaque black color.

Definition at line 45 of file ColorRgba.cpp.

ColorRgba const & blue ( )
static

Opaque blue color.

Definition at line 39 of file ColorRgba.cpp.

ColorRgba const & brown ( )
static

Opaque brown color.

Definition at line 43 of file ColorRgba.cpp.

ColorRgba const & cyan ( )
static

Opaque cyan color.

Definition at line 41 of file ColorRgba.cpp.

Real const* data ( ) const

Get the address of the array storing color channel values in RGBA order.

Definition at line 112 of file ColorRgba.hpp.

Real* data ( )

Get the address of the array storing color channel values in RGBA order.

Definition at line 115 of file ColorRgba.hpp.

void fill ( Real  v)

Set all channels to the same value.

Definition at line 141 of file ColorRgba.hpp.

ColorRgba fromARGB ( uint32  argb)
static

Initialize from an HTML-style color (e.g.

0xFFFF0000 == RED)

Definition at line 73 of file ColorRgba.cpp.

bool fuzzyEq ( ColorRgba const &  other) const

Check if two colors are approximately equal.

Definition at line 246 of file ColorRgba.hpp.

bool fuzzyNe ( ColorRgba const &  other) const

Check if two colors are not approximately equal.

Definition at line 252 of file ColorRgba.hpp.

Real g ( ) const

The value of the green channel.

Definition at line 91 of file ColorRgba.hpp.

Real& g ( )

A reference to the green channel.

Definition at line 94 of file ColorRgba.hpp.

ColorRgba const & gray ( )
static

Opaque gray color.

Definition at line 46 of file ColorRgba.cpp.

ColorRgba const & green ( )
static

Opaque green color.

Definition at line 38 of file ColorRgba.cpp.

ColorRgba operator* ( Real  s) const

Multiplication by a scalar.

Definition at line 156 of file ColorRgba.hpp.

ColorRgba operator* ( ColorRgba const &  rhs) const

Component-wise multiplication by another color.

Definition at line 162 of file ColorRgba.hpp.

ColorRgba& operator*= ( ColorRgba const &  rhs)

Multiply component-wise and assign.

Definition at line 206 of file ColorRgba.hpp.

ColorRgba& operator*= ( Real  s)

Multiply by a scalar and assign.

Definition at line 226 of file ColorRgba.hpp.

ColorRgba operator+ ( ColorRgba const &  rhs) const

Addition.

Definition at line 144 of file ColorRgba.hpp.

ColorRgba& operator+= ( ColorRgba const &  rhs)

Add and assign.

Definition at line 186 of file ColorRgba.hpp.

ColorRgba operator- ( ColorRgba const &  rhs) const

Subtraction.

Definition at line 150 of file ColorRgba.hpp.

ColorRgba operator- ( ) const

Negation of the color.

Definition at line 180 of file ColorRgba.hpp.

ColorRgba& operator-= ( ColorRgba const &  rhs)

Subtract and assign.

Definition at line 196 of file ColorRgba.hpp.

ColorRgba operator/ ( Real  s) const

Division by a scalar.

Definition at line 168 of file ColorRgba.hpp.

ColorRgba operator/ ( ColorRgba const &  rhs) const

Component-wise division by another color.

Definition at line 174 of file ColorRgba.hpp.

ColorRgba& operator/= ( ColorRgba const &  rhs)

Divide component-wise and assign.

Definition at line 216 of file ColorRgba.hpp.

ColorRgba& operator/= ( Real  s)

Divide by a scalar and assign.

Definition at line 236 of file ColorRgba.hpp.

Real const& operator[] ( IntegerT  channel) const

Array-style channel access.

Definition at line 118 of file ColorRgba.hpp.

Real& operator[] ( IntegerT  channel)

Array-style channel access.

Definition at line 125 of file ColorRgba.hpp.

ColorRgba const & orange ( )
static

Opaque orange color.

Definition at line 44 of file ColorRgba.cpp.

ColorRgba const & purple ( )
static

Opaque purple color.

Definition at line 40 of file ColorRgba.cpp.

Real r ( ) const

The value of the red channel.

Definition at line 85 of file ColorRgba.hpp.

Real& r ( )

A reference to the red channel.

Definition at line 88 of file ColorRgba.hpp.

ColorRgba const & red ( )
static

Opaque red color.

Definition at line 37 of file ColorRgba.cpp.

ColorRgb rgb ( ) const

Get the red, green and blue channels as a ColorRgb.

Definition at line 109 of file ColorRgba.hpp.

void set ( Real  r_,
Real  g_,
Real  b_,
Real  a_ 
)

Set all channels simultaneously.

Definition at line 132 of file ColorRgba.hpp.

std::string toString ( ) const

Get a string representation of the color.

Definition at line 82 of file ColorRgba.cpp.

ColorRgba const & white ( )
static

Opaque white color.

Definition at line 47 of file ColorRgba.cpp.

ColorRgba const & yellow ( )
static

Opaque yellow color.

Definition at line 42 of file ColorRgba.cpp.

ColorRgba const & zero ( )
static

Color with all channels zero (transparent black).

Definition at line 50 of file ColorRgba.cpp.


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