tbx  0.7.3
Public Types | Public Member Functions | List of all members
tbx::Colour Class Reference

Class to represent a RGB colour. More...

#include <colour.h>

Public Types

enum  {
  black = 0x00000000, white = 0xFFFFFF00, light_red = 0x0000FF00, light_green = 0x00FF0000,
  light_blue = 0xFF000000, magenta = 0xFFFF0000, yellow = 0x00FFFF00, cyan = 0xFFFF0000,
  wimp_grey0 = 0xFFFFFF00, wimp_grey1 = 0xDDDDDD00, wimp_grey2 = 0xBBBBBB00, wimp_grey3 = 0x99999900,
  wimp_grey4 = 0x77777700, wimp_grey5 = 0x55555500, wimp_grey6 = 0x33333300, wimp_grey7 = 0x00000000,
  wimp_dark_blue = 0x99440000, wimp_yellow = 0x00EEEE00, wimp_light_green = 0x00CC0000, wimp_red = 0x0000DD00,
  wimp_cream = 0xBBEEEE00, wimp_dark_green = 0x00885500, wimp_orange = 0x00BBFF00, wimp_light_blue = 0xFFBB0000,
  no_colour = 0xFFFFFFFF
}
 Enumeration of some common colours.
 

Public Member Functions

 Colour ()
 Default constructor (creates black)
 
 Colour (unsigned c)
 Construct from a packed colour. More...
 
 Colour (int red, int green, int blue)
 Construct colour from rgb components. More...
 
void red (int r)
 Change the red component of the colour. More...
 
void green (int g)
 Change the green component of the colour. More...
 
void blue (int b)
 Change the blue component of the colour. More...
 
int red () const
 Return the amount of red in the colour. More...
 
int green () const
 Return the amount of green in the colour. More...
 
int blue () const
 Return the amount of blue in the colour. More...
 
 operator unsigned () const
 Return the colours packed into an unsigned integer. More...
 
Colouroperator= (unsigned c)
 Set the colour from an unsigned integer. More...
 

Detailed Description

Class to represent a RGB colour.

The colour is stored as an unsigned integer in the format 0xbbggrrxx where xx is normally 0 rr is the red component gg is the green component bb is the blue component. All components set to 0xFF (255) is used to represent no colour.

Constructor & Destructor Documentation

tbx::Colour::Colour ( unsigned  c)
inline

Construct from a packed colour.

Parameters
ccolour in format 0xbbggrrxx
tbx::Colour::Colour ( int  red,
int  green,
int  blue 
)
inline

Construct colour from rgb components.

Each component consists of a value from 0 to 255 with 0 being none and 255 being full.

Parameters
redamount of red 0 to 255
greenamount of green 0 to 255
blueamount of blue 0 to 255

Member Function Documentation

void tbx::Colour::blue ( int  b)
inline

Change the blue component of the colour.

Parameters
bamount of blue from 0 to 255
int tbx::Colour::blue ( ) const
inline

Return the amount of blue in the colour.

Returns
amount of blue from 0 to 255
void tbx::Colour::green ( int  g)
inline

Change the green component of the colour.

Parameters
gamount of green from 0 to 255
int tbx::Colour::green ( ) const
inline

Return the amount of green in the colour.

Returns
amount of green from 0 to 255
tbx::Colour::operator unsigned ( ) const
inline

Return the colours packed into an unsigned integer.

Returns
the colour in the form 0xbbggrrxx
Colour& tbx::Colour::operator= ( unsigned  c)
inline

Set the colour from an unsigned integer.

Parameters
ccolour in the format 0xbbggrrxx
Returns
a reference to this colour
void tbx::Colour::red ( int  r)
inline

Change the red component of the colour.

Parameters
ramount of red from 0 to 255
int tbx::Colour::red ( ) const
inline

Return the amount of red in the colour.

Returns
amount of red from 0 to 255

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