# ColorC

# Class hierarchy

ColorC

# Overview

Color class defines a four component color type. The components are red, green, blue and alpha. All components are handled similar inside the class.

This class is implemented by the system.

Header: | ColorC.h
Library: | core.lib

# Class members

`ColorC( const ColorC& rCol );`

#### Parameters

rCol
  Reference to the color to copy.

#### Remarks

Copy constructor. Creates a new color with the same values as the argument.

`ColorC( float32 f32R float32 f32G float32 f32B float32 f32A = 1.0f );`

#### Parameters

f32R
  The Red component of the color. Range 0..1.
f32G
  The Green component of the color. Range 0..1.
f32B
  The Blue component of the color. Range 0..1.
f32A
  The Alpha (transparency) component of the color. Range 0..1. Default 1.0.

#### Remarks

Creates a new color with the values as the arguments.

`void convert_from_uint8( uint8 ui8R uint8 ui8G uint8 ui8B uint8 ui8A );`

#### Parameters

ui8R
  The Red component of the color. Range 0..255.
ui8G
  The Green component of the color. Range 0..255.
ui8B
  The Blue component of the color. Range 0..255.
ui8A
  The Alpha (transparency) component of the color. Range 0..255. Default 255.

#### Remarks

Converts color from unsigned integer values. All values are in range 0..255.

#### Example

`operator(const float32*();`

#### Return value

Pointer to the color components.

#### Remarks

Returns pointer to the color components of the color. This method is useful to pass an array of data to the for example rendering API.

#### Example

`ColorC rCol( 0.2, 0,3, 0.1, 0.7 );
glColor4fv( rCol );
`

`float32& operator[]( int32 i );`

`const float32& operator[]( int32 i ) const;`

#### Parameters

i
  Index to the component to get. Range 0..3.

#### Return value

Reference to the color component pointed by the index.

#### Remarks

The index values from 0 to 3 corresponds to components R, G, B, and A respectively. There are two versions of this method, the first enables to assign values and the second is for retrieving the values.

`ColorC operator-() const;`

#### Return value

Negated color.

`bool operator==( const ColorC& rCol ) const;`

#### Return value

True if both colors are equal, else false.

`bool operator!=( const ColorC& rCol ) const;`

#### Return value

True if colors are not equal, else false.

`ColorC& operator-=( const ColorC& rCol );`

#### Remarks

Subtracts the color specified by the argument from the color.

`ColorC& operator+=( const ColorC& rCol );`

#### Remarks

Adds the color specified by the argument to the color.

`ColorC& operator*=( float32 f32S );`

#### Remarks

Multiplies each color component by the specified number.

`ColorC& operator/=( float32 f32S );`

#### Remarks

Divides each color component by the specified number.

`ColorC operator*( float32 f32S ) const;`

#### Remarks

Multiplies each color component by the specified number and returns the result.

`ColorC operator/( float32 f32S ) const;`

#### Remarks

Divides each color component by the specified number and returns the result.

`ColorC operator-( const ColorC& rCol ) const;`

#### Remarks

Subtracts the color specified by the argument from the color and returns the result.

`ColorC operator+( const ColorC& rCol ) const;`

#### Remarks

Adds the color specified by the argument to the color and returns the result.

`ColorC operator*( const ColorC& rCol ) const;`

#### Remarks

Multiplies each component of the color by matching component in the specified argument and returns the result.

`friend ColorC operator*( float32 f32S const ColorC& rCol );`

#### Remarks

Multiplies each color component by the specified number and returns the result.

Copyright © 2000 Moppi Productions