Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members

# ptc::Color Class Reference

Describes a pixel color. More...

List of all members.

## Public Members

- Color ()
- Color (int index)
- Color (float r,float g,float b,float a=1.0f)
- Color (const Color &color)
- ~Color ()
- int index () const
- float r () const
- float g () const
- float b () const
- float a () const
- bool direct () const
- bool indexed () const
- Color& operator= (const Color &color)
- bool operator== (const Color &color) const
- bool operator!= (const Color &color) const

## Detailed Description

Describes a pixel color.

The color class can describe one of two types of color: direct color, or indexed color.

Indexed color is an index value into a palette and direct color is an set of red, green, blue and alpha values.

Color objects are typically used with surface and console routines Surface::clear(const Color &color) and Console::clear(const Color &color).

## Member Function Documentation

### ptc::Color::Color ()

Default constructor.

index, r, g, b and a are all set to zero.

### ptc::Color::Color (int index)

Creates an indexed color object referring to the palette color at index.

For 8 bit indexed modes the palette has 256 entries, therefore the index value should be in the range of [ 0, 255 ].

See also:
  Palette class

Parameters:
  index - the color index.

### ptc::Color::Color (float r, float g, float b, float a = 1.0f)

Creates a direct color object with specific red, green, blue and alpha values.

The r, g, b and a values should all be set in the range of [ 0.0f, 1.0f ] where 0.0f represents minimum intensity and 1.0f represents maximum intensity.

For example, a color created with Color(0.0f,0.0f,0.0f) represents black, and a color created by Color(1.0f,1.0f,1.0f) represents white.

Parameters:
  r - the red color component.
  g - the green color component.
  b - the blue color component.
  a - the alpha color component (defaults to one).

### ptc::Color::Color (const Color & color)

Copy constructor.

### ptc::Color::~Color ()

Destructor.

### int ptc::Color::index () const

Gets the palette index value of the color.

The palette index is only valid if the color is indexed.

A color object is an indexed color if it was created by the Color::Color(int index) constructor.

If the color object is not indexed color then the index value is always zero.

Returns:
  The color index.

### float ptc::Color::r () const

Gets the red color component of the color object.

The red color component is only valid if the color object is direct color.

A color object is direct color if it was created by the Color::Color(float r,float g,float b,float a) constructor.

If the color object is not direct color then the red component is always zero.

Returns:
  The red color component.

### float ptc::Color::g () const

Gets the green color component of the color object.

The green color component is only valid if the color object is direct color.

A color object is direct color if it was created by the Color::Color(float r,float g,float b,float a) constructor.

If the color object is not direct color then the green component is always zero.

Returns:
  The green color component.

### float ptc::Color::b () const

Gets the blue color component of the color object.

The blue color component is only valid if the color object is direct color.

A color object is direct color if it was created by the Color::Color(float r,float g,float b,float a) constructor.

If the color object is not direct color then the blue component is always zero.

Returns:
  The blue color component.

### float ptc::Color::a () const

Gets the alpha color component of the color object.

The alpha color component is only valid if the color object is direct color.

A color object is direct color if it was created by the Color::Color(float r,float g,float b,float a) constructor.

If the color object is not direct color then the alpha component is always zero.

Returns:
  The alpha color component.

### bool ptc::Color::direct () const

Checks if the color is direct color.

A color object is direct color if it was created by the Color::Color(float r,float g,float b,float a) constructor.

Returns:
  true if the color is direct color, false otherwise.

### bool ptc::Color::indexed () const

Checks if the color is indexed color.

A color object is indexed color if it was created by the Color::Color(int index) constructor.

Returns:
  true if the color is indexed color, false otherwise.

### Color & ptc::Color::operator= (const Color & color)

Assignment operator.

### bool ptc::Color::operator== (const Color & color) const

Equality operator.

### bool ptc::Color::operator!= (const Color & color) const

Inequality operator.

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

- ptc.h