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

A color with four byte-sized channels: red, green, blue and alpha, each in [0, 255]. More...

#include <ColorRgba8.hpp>

Public Types

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

Public Member Functions

uint8 a () const
 The value of the alpha channel. More...
 
uint8 & a ()
 A reference to the alpha channel. More...
 
uint32 asUInt32 () const
 Get the color packed into a 32-bit unsigned integer. More...
 
uint8 b () const
 The value of the blue channel. More...
 
uint8 & b ()
 A reference to the blue channel. More...
 
ColorRgba8 bgra () const
 Swap the red and blue channels. More...
 
 ColorRgba8 ()
 Default constructor. More...
 
 ColorRgba8 (uint8 r_, uint8 g_, uint8 b_, uint8 a_)
 Construct from red, green, blue and alpha components. More...
 
 ColorRgba8 (ColorRgb8 const &rgb_, uint8 a_=255)
 Construct from an RGB color and an alpha component. More...
 
 ColorRgba8 (uint8 const *v)
 Construct a color from four components in an array. More...
 
 ColorRgba8 (ColorRgba const &src)
 Construct from a color with floating-point channels, with automatic scaling from [0, 1] to [0, 255]. More...
 
uint8 const * data () const
 Get the address of the array storing color channel values in RGBA order. More...
 
uint8 * data ()
 Get the address of the array storing color channel values in RGBA order. More...
 
void fill (uint8 v)
 Set all channels to the same value. More...
 
uint8 g () const
 The value of the green channel. More...
 
uint8 & g ()
 A reference to the green channel. More...
 
ColorRgba8 operator* (Real s) const
 Multiplication by a scalar. More...
 
ColorRgba8operator*= (Real s)
 Multiply by a scalar and assign. More...
 
ColorRgba8 operator+ (ColorRgba8 const &rhs) const
 Addition. More...
 
ColorRgba8operator+= (ColorRgba8 const &rhs)
 Add and assign. More...
 
ColorRgba8 operator- (ColorRgba8 const &rhs) const
 Subtraction. More...
 
ColorRgba8operator-= (ColorRgba8 const &rhs)
 Subtract and assign. More...
 
ColorRgba8 operator/ (Real s) const
 Division by a scalar. More...
 
ColorRgba8operator/= (Real s)
 Divide by a scalar and assign. More...
 
template<typename IntegerT >
uint8 const & operator[] (IntegerT channel) const
 Array-style channel access. More...
 
template<typename IntegerT >
uint8 & operator[] (IntegerT channel)
 Array-style channel access. More...
 
uint8 r () const
 The value of the red channel. More...
 
uint8 & r ()
 A reference to the red channel. More...
 
ColorRgb8 rgb () const
 Get the red, green and blue channels as a ColorRgb8. More...
 
void set (uint8 r_, uint8 g_, uint8 b_, uint8 a_)
 Set all channels simultaneously. More...
 
std::string toString () const
 Get a string representation of the color. More...
 

Static Public Member Functions

static ColorRgba8 fromARGB (uint32 argb)
 Initialize from an HTML-style color (e.g. More...
 

Detailed Description

A color with four byte-sized channels: red, green, blue and alpha, each in [0, 255].

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

Definition at line 47 of file ColorRgba8.hpp.

Member Typedef Documentation

typedef uint8 value_type

The numerical type of each channel.

Definition at line 53 of file ColorRgba8.hpp.

Constructor & Destructor Documentation

Default constructor.

Does not initialize fields.

Definition at line 56 of file ColorRgba8.hpp.

ColorRgba8 ( uint8  r_,
uint8  g_,
uint8  b_,
uint8  a_ 
)

Construct from red, green, blue and alpha components.

Definition at line 59 of file ColorRgba8.hpp.

ColorRgba8 ( ColorRgb8 const &  rgb_,
uint8  a_ = 255 
)

Construct from an RGB color and an alpha component.

Definition at line 62 of file ColorRgba8.hpp.

ColorRgba8 ( uint8 const *  v)
explicit

Construct a color from four components in an array.

Definition at line 65 of file ColorRgba8.hpp.

ColorRgba8 ( ColorRgba const &  src)

Construct from a color with floating-point channels, with automatic scaling from [0, 1] to [0, 255].

Definition at line 32 of file ColorRgba8.cpp.

Member Function Documentation

uint8 a ( ) const

The value of the alpha channel.

Definition at line 92 of file ColorRgba8.hpp.

uint8& a ( )

A reference to the alpha channel.

Definition at line 95 of file ColorRgba8.hpp.

uint32 asUInt32 ( ) const

Get the color packed into a 32-bit unsigned integer.

The most significant byte is alpha, the next byte is red, then green, then blue. Note that the actual memory ordering of the bytes depends upon the endianness of the system.

Definition at line 206 of file ColorRgba8.hpp.

uint8 b ( ) const

The value of the blue channel.

Definition at line 86 of file ColorRgba8.hpp.

uint8& b ( )

A reference to the blue channel.

Definition at line 89 of file ColorRgba8.hpp.

ColorRgba8 bgra ( ) const

Swap the red and blue channels.

Definition at line 197 of file ColorRgba8.hpp.

uint8 const* data ( ) const

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

Definition at line 101 of file ColorRgba8.hpp.

uint8* data ( )

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

Definition at line 104 of file ColorRgba8.hpp.

void fill ( uint8  v)

Set all channels to the same value.

Definition at line 130 of file ColorRgba8.hpp.

ColorRgba8 fromARGB ( uint32  argb)
static

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

0xFF0000 == RED)

Definition at line 41 of file ColorRgba8.cpp.

uint8 g ( ) const

The value of the green channel.

Definition at line 80 of file ColorRgba8.hpp.

uint8& g ( )

A reference to the green channel.

Definition at line 83 of file ColorRgba8.hpp.

ColorRgba8 operator* ( Real  s) const

Multiplication by a scalar.

Channels are rounded to the nearest byte values.

Definition at line 151 of file ColorRgba8.hpp.

ColorRgba8& operator*= ( Real  s)

Multiply by a scalar and assign.

Channels are rounded to the nearest byte values.

Definition at line 183 of file ColorRgba8.hpp.

ColorRgba8 operator+ ( ColorRgba8 const &  rhs) const

Addition.

Upper-bounds channels to 255.

Definition at line 133 of file ColorRgba8.hpp.

ColorRgba8& operator+= ( ColorRgba8 const &  rhs)

Add and assign.

Upper-bounds channels to 255.

Definition at line 169 of file ColorRgba8.hpp.

ColorRgba8 operator- ( ColorRgba8 const &  rhs) const

Subtraction.

Lower-bounds channels to 0.

Definition at line 142 of file ColorRgba8.hpp.

ColorRgba8& operator-= ( ColorRgba8 const &  rhs)

Subtract and assign.

Lower-bounds channels to 0.

Definition at line 176 of file ColorRgba8.hpp.

ColorRgba8 operator/ ( Real  s) const

Division by a scalar.

Channels are rounded to the nearest byte values.

Definition at line 160 of file ColorRgba8.hpp.

ColorRgba8& operator/= ( Real  s)

Divide by a scalar and assign.

Channels are rounded to the nearest byte values.

Definition at line 190 of file ColorRgba8.hpp.

uint8 const& operator[] ( IntegerT  channel) const

Array-style channel access.

Definition at line 107 of file ColorRgba8.hpp.

uint8& operator[] ( IntegerT  channel)

Array-style channel access.

Definition at line 114 of file ColorRgba8.hpp.

uint8 r ( ) const

The value of the red channel.

Definition at line 74 of file ColorRgba8.hpp.

uint8& r ( )

A reference to the red channel.

Definition at line 77 of file ColorRgba8.hpp.

ColorRgb8 rgb ( ) const

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

Definition at line 98 of file ColorRgba8.hpp.

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

Set all channels simultaneously.

Definition at line 121 of file ColorRgba8.hpp.

std::string toString ( ) const

Get a string representation of the color.

Definition at line 50 of file ColorRgba8.cpp.


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