CrystalSpace

Public API Reference

csColor Class Reference

A class used to represent a color in RGB space. More...

#include <csutil/cscolor.h>

Inheritance diagram for csColor:

List of all members.

Public Member Functions

void Add (float r, float g, float b)
 Add given R,G,B components to color.
void Clamp (float r, float g, float b)
 Clamp color to given R,G,B values.
void ClampDown ()
 Make sure color components are not negative.
 csColor (const csColor &c)
 Initialize a color object with an existing color.
 csColor (float v)
 Initialize a color object with same content in R,G,B components.
 csColor (float r, float g, float b)
 Initialize a color object with given R,G,B components.
 csColor ()
 Initialize a color object (contents undefined).
bool IsBlack (float threshold) const
 Check if color is all black (red green and blue all below threshold).
bool IsBlack () const
 Check if color is all black (red green and blue all 0).
float Luminance () const
 Return luminance of pixel (assuming sRGB color space).
bool operator!= (const csColor &c) const
 Compare inequality of two colors.
csColor operator* (const float f)
 Multiply this color by a scalar, return result.
csColoroperator*= (const csColor &c)
 Multiply another color with this one.
csColoroperator*= (float f)
 Multiply this color by a scalar value.
csColoroperator+= (const csColor &c)
 Add another color to this one.
csColoroperator-= (const csColor &c)
 Subtract another color to this one.
csColoroperator= (const csColor &c)
 Assign one color object to another.
bool operator== (const csColor &c) const
 Compare equality of two colors.
float & operator[] (size_t n)
 Returns n-th component of the color.
float operator[] (size_t n) const
 Returns n-th component of the color.
void Set (const csColor &c)
 Set color to given color.
void Set (float r, float g, float b)
 Set color to given R,G,B components.
void Subtract (float r, float g, float b)
 Subtract given R,G,B components from color.

Detailed Description

A class used to represent a color in RGB space.

This class is similar to csRGBpixel and csRGBcolor except that it uses floating-point values to store R,G,B values.

Definition at line 33 of file cscolor.h.


Constructor & Destructor Documentation

csColor::csColor (  )  [inline]

Initialize a color object (contents undefined).

Definition at line 57 of file cscolor.h.

csColor::csColor ( float  r,
float  g,
float  b 
) [inline]

Initialize a color object with given R,G,B components.

Definition at line 59 of file cscolor.h.

csColor::csColor ( float  v  )  [inline]

Initialize a color object with same content in R,G,B components.

Definition at line 62 of file cscolor.h.

csColor::csColor ( const csColor c  )  [inline]

Initialize a color object with an existing color.

Definition at line 65 of file cscolor.h.


Member Function Documentation

void csColor::Add ( float  r,
float  g,
float  b 
) [inline]

Add given R,G,B components to color.

Definition at line 128 of file cscolor.h.

void csColor::Clamp ( float  r,
float  g,
float  b 
) [inline]

Clamp color to given R,G,B values.

Definition at line 74 of file cscolor.h.

void csColor::ClampDown (  )  [inline]

Make sure color components are not negative.

Definition at line 81 of file cscolor.h.

bool csColor::IsBlack ( float  threshold  )  const [inline]

Check if color is all black (red green and blue all below threshold).

Definition at line 93 of file cscolor.h.

bool csColor::IsBlack (  )  const [inline]

Check if color is all black (red green and blue all 0).

Definition at line 88 of file cscolor.h.

float csColor::Luminance (  )  const [inline]

Return luminance of pixel (assuming sRGB color space).

Definition at line 134 of file cscolor.h.

bool csColor::operator!= ( const csColor c  )  const [inline]

Compare inequality of two colors.

Reimplemented in csColor4.

Definition at line 125 of file cscolor.h.

csColor csColor::operator* ( const float  f  )  [inline]

Multiply this color by a scalar, return result.

Definition at line 113 of file cscolor.h.

csColor& csColor::operator*= ( const csColor c  )  [inline]

Multiply another color with this one.

Definition at line 110 of file cscolor.h.

csColor& csColor::operator*= ( float  f  )  [inline]

Multiply this color by a scalar value.

Reimplemented in csColor4.

Definition at line 101 of file cscolor.h.

csColor& csColor::operator+= ( const csColor c  )  [inline]

Add another color to this one.

Reimplemented in csColor4.

Definition at line 104 of file cscolor.h.

csColor& csColor::operator-= ( const csColor c  )  [inline]

Subtract another color to this one.

Reimplemented in csColor4.

Definition at line 107 of file cscolor.h.

csColor& csColor::operator= ( const csColor c  )  [inline]

Assign one color object to another.

Reimplemented in csColor4.

Definition at line 98 of file cscolor.h.

bool csColor::operator== ( const csColor c  )  const [inline]

Compare equality of two colors.

Reimplemented in csColor4.

Definition at line 122 of file cscolor.h.

float& csColor::operator[] ( size_t  n  )  [inline]

Returns n-th component of the color.

Reimplemented in csColor4.

Definition at line 148 of file cscolor.h.

float csColor::operator[] ( size_t  n  )  const [inline]

Returns n-th component of the color.

Reimplemented in csColor4.

Definition at line 141 of file cscolor.h.

void csColor::Set ( const csColor c  )  [inline]

Set color to given color.

Reimplemented in csColor4.

Definition at line 71 of file cscolor.h.

void csColor::Set ( float  r,
float  g,
float  b 
) [inline]

Set color to given R,G,B components.

Reimplemented in csColor4.

Definition at line 68 of file cscolor.h.

void csColor::Subtract ( float  r,
float  g,
float  b 
) [inline]

Subtract given R,G,B components from color.

Definition at line 131 of file cscolor.h.


Member Data Documentation

Blue (0..1).

Definition at line 47 of file cscolor.h.

Green (0..1).

Definition at line 45 of file cscolor.h.

float csColor::m[3]

All components.

Definition at line 51 of file cscolor.h.

float csColor::red

Red (0..1).

Definition at line 43 of file cscolor.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1