Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# irr::video::SColor Class Reference

Class representing a 32 bit ARGB color. More...

`#include <SColor.h>`

List of all members.

## Public Member Functions
u32 | getAlpha () const
| Returns the alpha component of the color.
u32 | getAverage () const
| Get average intensity of the color in the range [0,255].
u32 | getBlue () const
| Returns the blue component of the color.
u32 | getGreen () const
| Returns the green component of the color.
SColor | getInterpolated (const SColor &other, f32 d) const
| Interpolates the color with a f32 value to another color.
SColor | getInterpolated_quadratic (const SColor &c1, const SColor &c2, f32 d) const
| Returns interpolated color. ( quadratic ).
f32 | getLightness () const
| Get lightness of the color in the range [0,255].
f32 | getLuminance () const
| Get luminance of the color in the range [0,255].
u32 | getRed () const
| Returns the red component of the color.
bool | operator!= (const SColor &other) const
| Compares the color to another color.
SColor | operator+ (const SColor &other) const
| Adds two colors, result is clamped to 0..255 values.
bool | operator< (const SColor &other) const
| comparison operator
bool | operator== (const SColor &other) const
| Compares the color to another color.
| SColor (u32 clr)
| Constructs the color from a 32 bit value. Could be another color.
| SColor (u32 a, u32 r, u32 g, u32 b)
| Constructs the color from 4 values representing the alpha, red, green and blue component.
| SColor ()
| Constructor of the Color. Does nothing.
void | set (u32 col)
void | set (u32 a, u32 r, u32 g, u32 b)
| Sets all four components of the color at once.
void | setAlpha (u32 a)
| Sets the alpha component of the Color.
void | setBlue (u32 b)
| Sets the blue component of the Color.
void | setGreen (u32 g)
| Sets the green component of the Color.
void | setRed (u32 r)
| Sets the red component of the Color.
u16 | toA1R5G5B5 () const
| Calculates a 16 bit A1R5G5B5 value of this color.
void | toOpenGLColor (u8 *dest) const
| Converts color to OpenGL color format.
## Public Attributes
u32 | color
| color in A8R8G8B8 Format

## Detailed Description

Class representing a 32 bit ARGB color.

The color values for alpha, red, green, and blue are stored in a single u32. So all four values may be between 0 and 255. Alpha in Irrlicht is opacity, so 0 is fully transparent, 255 is fully opaque (solid). This class is used by most parts of the Irrlicht Engine to specify a color. Another way is using the class SColorf, which stores the color values in 4 floats. This class must consist of only one u32 and must not use virtual functions.

Definition at line 157 of file SColor.h.

## Constructor & Destructor Documentation

irr::video::SColor::SColor | ( |  | ) | `[inline]`

Constructor of the Color. Does nothing.

The color value is not initialized to save time.

Definition at line 163 of file SColor.h.

Referenced by getInterpolated(), getInterpolated_quadratic(), and operator+().

irr::video::SColor::SColor | ( | u32 | a,
|  | u32 | r,
|  | u32 | g,
|  | u32 | b |
| ) |  |  | `[inline]`

Constructs the color from 4 values representing the alpha, red, green and blue component.

Must be values between 0 and 255.

Definition at line 167 of file SColor.h.

irr::video::SColor::SColor | ( | u32 | clr | ) | `[inline]`

Constructs the color from a 32 bit value. Could be another color.

Definition at line 171 of file SColor.h.

## Member Function Documentation

u32 irr::video::SColor::getAlpha | ( |  | ) | const`[inline]`

Returns the alpha component of the color.

The alpha component defines how opaque a color is.

Returns:
  The alpha value of the color. 0 is fully transparent, 255 is fully opaque.

Definition at line 177 of file SColor.h.

References color.

Referenced by getInterpolated(), getInterpolated_quadratic(), operator+(), irr::video::SColorf::SColorf(), and toOpenGLColor().

u32 irr::video::SColor::getAverage | ( |  | ) | const`[inline]`

Get average intensity of the color in the range [0,255].

Definition at line 207 of file SColor.h.

References getBlue(), getGreen(), and getRed().

u32 irr::video::SColor::getBlue | ( |  | ) | const`[inline]`

Returns the blue component of the color.

Returns:
  Value between 0 and 255, specifying how blue the color is. 0 means no blue, 255 means full blue.

Definition at line 192 of file SColor.h.

References color.

Referenced by irr::video::SColorHSL::fromRGB(), getAverage(), getInterpolated(), getInterpolated_quadratic(), getLightness(), getLuminance(), operator+(), irr::video::SColorf::SColorf(), and toOpenGLColor().

u32 irr::video::SColor::getGreen | ( |  | ) | const`[inline]`

Returns the green component of the color.

Returns:
  Value between 0 and 255, specifying how green the color is. 0 means no green, 255 means full green.

Definition at line 187 of file SColor.h.

References color.

Referenced by irr::video::SColorHSL::fromRGB(), getAverage(), getInterpolated(), getInterpolated_quadratic(), getLightness(), getLuminance(), operator+(), irr::video::SColorf::SColorf(), and toOpenGLColor().

SColor irr::video::SColor::getInterpolated | ( | const SColor & | other,
|  | f32 | d |
| ) |  |  | const`[inline]`

Interpolates the color with a f32 value to another color.

Parameters:

  | other,: | Other color
  | d,: | value between 0.0f and 1.0f

Returns:
  Interpolated color.

Definition at line 296 of file SColor.h.

References irr::core::clamp(), getAlpha(), getBlue(), getGreen(), getRed(), irr::core::round32(), and SColor().

SColor irr::video::SColor::getInterpolated_quadratic | ( | const SColor & | c1,
|  | const SColor & | c2,
|  | f32 | d |
| ) |  |  | const`[inline]`

Returns interpolated color. ( quadratic ).

Parameters:

  | c1,: | first color to interpolate with
  | c2,: | second color to interpolate with
  | d,: | value between 0.0f and 1.0f.

Definition at line 310 of file SColor.h.

References irr::core::clamp(), irr::core::floor32(), getAlpha(), getBlue(), getGreen(), getRed(), and SColor().

f32 irr::video::SColor::getLightness | ( |  | ) | const`[inline]`

Get lightness of the color in the range [0,255].

Definition at line 195 of file SColor.h.

References getBlue(), getGreen(), getRed(), irr::core::max_(), and irr::core::min_().

f32 irr::video::SColor::getLuminance | ( |  | ) | const`[inline]`

Get luminance of the color in the range [0,255].

Definition at line 201 of file SColor.h.

References getBlue(), getGreen(), and getRed().

u32 irr::video::SColor::getRed | ( |  | ) | const`[inline]`

Returns the red component of the color.

Returns:
  Value between 0 and 255, specifying how red the color is. 0 means no red, 255 means full red.

Definition at line 182 of file SColor.h.

References color.

Referenced by irr::video::SColorHSL::fromRGB(), getAverage(), getInterpolated(), getInterpolated_quadratic(), getLightness(), getLuminance(), operator+(), irr::video::SColorf::SColorf(), and toOpenGLColor().

bool irr::video::SColor::operator!= | ( | const SColor & | other | ) | const`[inline]`

Compares the color to another color.

Returns:
  True if the colors are different, and false if they are the same.

Definition at line 275 of file SColor.h.

References color.

SColor irr::video::SColor::operator+ | ( | const SColor & | other | ) | const`[inline]`

Adds two colors, result is clamped to 0..255 values.

Parameters:

  | other | Color to add to this color

Returns:
  Addition of the two colors, clamped to 0..255 values

Definition at line 284 of file SColor.h.

References getAlpha(), getBlue(), getGreen(), getRed(), irr::core::min_(), and SColor().

bool irr::video::SColor::operator< | ( | const SColor & | other | ) | const`[inline]`

comparison operator

Returns:
  True if this color is smaller than the other one

Definition at line 279 of file SColor.h.

References color.

bool irr::video::SColor::operator== | ( | const SColor & | other | ) | const`[inline]`

Compares the color to another color.

Returns:
  True if the colors are the same, and false if not.

Definition at line 271 of file SColor.h.

References color.

void irr::video::SColor::set | ( | u32 | col | ) | `[inline]`

Definition at line 267 of file SColor.h.

References color.

void irr::video::SColor::set | ( | u32 | a,
|  | u32 | r,
|  | u32 | g,
|  | u32 | b |
| ) |  |  | `[inline]`

Sets all four components of the color at once.

Constructs the color from 4 values representing the alpha, red, green and blue components of the color. Must be values between 0 and 255.

Parameters:

  | a,: | Alpha component of the color. The alpha component defines how transparent a color should be. Has to be a value between 0 and 255. 255 means not transparent (opaque), 0 means fully transparent.
  | r,: | Sets the red component of the Color. Has to be a value between 0 and 255. 0 means no red, 255 means full red.
  | g,: | Sets the green component of the Color. Has to be a value between 0 and 255. 0 means no green, 255 means full green.
  | b,: | Sets the blue component of the Color. Has to be a value between 0 and 255. 0 means no blue, 255 means full blue.

Definition at line 263 of file SColor.h.

References color.

void irr::video::SColor::setAlpha | ( | u32 | a | ) | `[inline]`

Sets the alpha component of the Color.

The alpha component defines how transparent a color should be.

Parameters:

  | a | The alpha value of the color. 0 is fully transparent, 255 is fully opaque.

Definition at line 215 of file SColor.h.

References color.

void irr::video::SColor::setBlue | ( | u32 | b | ) | `[inline]`

Sets the blue component of the Color.

Parameters:

  | b,: | Has to be a value between 0 and 255. 0 means no blue, 255 means full blue.

Definition at line 230 of file SColor.h.

References color.

Referenced by irr::video::SColorHSL::toRGB().

void irr::video::SColor::setGreen | ( | u32 | g | ) | `[inline]`

Sets the green component of the Color.

Parameters:

  | g,: | Has to be a value between 0 and 255. 0 means no green, 255 means full green.

Definition at line 225 of file SColor.h.

References color.

Referenced by irr::video::SColorHSL::toRGB().

void irr::video::SColor::setRed | ( | u32 | r | ) | `[inline]`

Sets the red component of the Color.

Parameters:

  | r,: | Has to be a value between 0 and 255. 0 means no red, 255 means full red.

Definition at line 220 of file SColor.h.

References color.

Referenced by irr::video::SColorHSL::toRGB().

u16 irr::video::SColor::toA1R5G5B5 | ( |  | ) | const`[inline]`

Calculates a 16 bit A1R5G5B5 value of this color.

Returns:
  16 bit A1R5G5B5 value of this color.

Definition at line 234 of file SColor.h.

References irr::video::A8R8G8B8toA1R5G5B5(), and color.

void irr::video::SColor::toOpenGLColor | ( | u8 * | dest | ) | const`[inline]`

Converts color to OpenGL color format.

From ARGB to RGBA in 4 byte components for endian aware passing to OpenGL

Parameters:

  | dest,: | address where the 4x8 bit OpenGL color is stored.

Definition at line 240 of file SColor.h.

References getAlpha(), getBlue(), getGreen(), and getRed().

## Member Data Documentation

u32 irr::video::SColor::color

color in A8R8G8B8 Format

Definition at line 331 of file SColor.h.

Referenced by getAlpha(), getBlue(), getGreen(), getRed(), operator!=(), operator<(), operator==(), set(), setAlpha(), setBlue(), setGreen(), setRed(), and toA1R5G5B5().

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

- SColor.h

| The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Oct 24 12:42:10 2010 by Doxygen (1.6.2)