Saga3D API Documentation  1.0-RC4
saga::video::SColor Class Reference

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

#include <SColor.h>

Public Member Functions

 SColor ()
 Constructor of the Color. Does nothing. More...
 
 SColor (std::uint32_t a, std::uint32_t r, std::uint32_t g, std::uint32_t b)
 Constructs the color from 4 values representing the alpha, red, green and blue component. More...
 
 SColor (std::uint32_t clr)
 Constructs the color from a 32 bit value. Could be another color. More...
 
std::uint32_t getAlpha () const
 Returns the alpha component of the color. More...
 
std::uint32_t getRed () const
 Returns the red component of the color. More...
 
std::uint32_t getGreen () const
 Returns the green component of the color. More...
 
std::uint32_t getBlue () const
 Returns the blue component of the color. More...
 
float getLightness () const
 Get lightness of the color in the range [0,255]. More...
 
float getLuminance () const
 Get luminance of the color in the range [0,255]. More...
 
std::uint32_t getAverage () const
 Get average intensity of the color in the range [0,255]. More...
 
void setAlpha (std::uint32_t a)
 Sets the alpha component of the Color. More...
 
void setRed (std::uint32_t r)
 Sets the red component of the Color. More...
 
void setGreen (std::uint32_t g)
 Sets the green component of the Color. More...
 
void setBlue (std::uint32_t b)
 Sets the blue component of the Color. More...
 
std::uint16_t toA1R5G5B5 () const
 Calculates a 16 bit A1R5G5B5 value of this color. More...
 
void toOpenGLColor (std::uint8_t *dest) const
 Converts color to OpenGL color format. More...
 
glm::uvec4 toGLM () const
 
void set (std::uint32_t a, std::uint32_t r, std::uint32_t g, std::uint32_t b)
 Sets all four components of the color at once. More...
 
void set (std::uint32_t col)
 
bool operator== (const SColor &other) const
 Compares the color to another color. More...
 
bool operator!= (const SColor &other) const
 Compares the color to another color. More...
 
bool operator< (const SColor &other) const
 comparison operator More...
 
SColor operator+ (const SColor &other) const
 Adds two colors, result is clamped to 0..255 values. More...
 
SColor getInterpolated (const SColor &other, float d) const
 Interpolates the color with a float value to another color. More...
 
SColor getInterpolated_quadratic (const SColor &c1, const SColor &c2, float d) const
 Returns interpolated color. (quadratic) More...
 
void setData (const void *data, E_PIXEL_FORMAT format)
 set the color by expecting data in the given format More...
 
void getData (void *data, E_PIXEL_FORMAT format) const
 Write the color to data in the defined format. More...
 

Public Attributes

std::uint32_t color
 color in A8RGB8 Format More...
 

Detailed Description

Class representing a 32 bit ARGB color.

The color values for alpha, red, green, and blue are stored in a single std::uint32_t. 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 std::uint32_t and must not use virtual functions.

Definition at line 197 of file SColor.h.

Constructor & Destructor Documentation

◆ SColor() [1/3]

saga::video::SColor::SColor ( )
inline

Constructor of the Color. Does nothing.

The color value is not initialized to save time.

Definition at line 203 of file SColor.h.

◆ SColor() [2/3]

saga::video::SColor::SColor ( std::uint32_t  a,
std::uint32_t  r,
std::uint32_t  g,
std::uint32_t  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 207 of file SColor.h.

◆ SColor() [3/3]

saga::video::SColor::SColor ( std::uint32_t  clr)
inline

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

Definition at line 211 of file SColor.h.

Member Function Documentation

◆ getAlpha()

std::uint32_t saga::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 217 of file SColor.h.

◆ getAverage()

std::uint32_t saga::video::SColor::getAverage ( ) const
inline

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

Definition at line 247 of file SColor.h.

◆ getBlue()

std::uint32_t saga::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 232 of file SColor.h.

◆ getData()

void saga::video::SColor::getData ( void *  data,
E_PIXEL_FORMAT  format 
) const
inline

Write the color to data in the defined format.

Parameters
datatarget to write the color. Must contain sufficiently large memory to receive the number of bytes neede for format
formattells the format used to write the color into data

Definition at line 402 of file SColor.h.

◆ getGreen()

std::uint32_t saga::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 227 of file SColor.h.

◆ getInterpolated()

SColor saga::video::SColor::getInterpolated ( const SColor other,
float  d 
) const
inline

Interpolates the color with a float value to another color.

Parameters
otherOther color
dvalue between 0.0f and 1.0f
Returns
Interpolated color.

Definition at line 338 of file SColor.h.

◆ getInterpolated_quadratic()

SColor saga::video::SColor::getInterpolated_quadratic ( const SColor c1,
const SColor c2,
float  d 
) const
inline

Returns interpolated color. (quadratic)

Parameters
c1first color to interpolate with
c2second color to interpolate with
dvalue between 0.0f and 1.0f.

Definition at line 352 of file SColor.h.

◆ getLightness()

float saga::video::SColor::getLightness ( ) const
inline

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

Definition at line 235 of file SColor.h.

◆ getLuminance()

float saga::video::SColor::getLuminance ( ) const
inline

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

Definition at line 241 of file SColor.h.

◆ getRed()

std::uint32_t saga::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 222 of file SColor.h.

◆ operator!=()

bool saga::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 317 of file SColor.h.

◆ operator+()

SColor saga::video::SColor::operator+ ( const SColor other) const
inline

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

Parameters
otherColor to add to this color
Returns
Addition of the two colors, clamped to 0..255 values

Definition at line 326 of file SColor.h.

◆ operator<()

bool saga::video::SColor::operator< ( const SColor other) const
inline

comparison operator

Returns
True if this color is smaller than the other one

Definition at line 321 of file SColor.h.

◆ operator==()

bool saga::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 313 of file SColor.h.

◆ set() [1/2]

void saga::video::SColor::set ( std::uint32_t  a,
std::uint32_t  r,
std::uint32_t  g,
std::uint32_t  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
aAlpha 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.
rSets the red component of the Color. Has to be a value between 0 and 255. 0 means no red, 255 means full red.
gSets the green component of the Color. Has to be a value between 0 and 255. 0 means no green, 255 means full green.
bSets 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 305 of file SColor.h.

◆ set() [2/2]

void saga::video::SColor::set ( std::uint32_t  col)
inline

Definition at line 309 of file SColor.h.

◆ setAlpha()

void saga::video::SColor::setAlpha ( std::uint32_t  a)
inline

Sets the alpha component of the Color.

The alpha component defines how transparent a color should be.

Parameters
aThe alpha value of the color. 0 is fully transparent, 255 is fully opaque.

Definition at line 255 of file SColor.h.

◆ setBlue()

void saga::video::SColor::setBlue ( std::uint32_t  b)
inline

Sets the blue component of the Color.

Parameters
bHas to be a value between 0 and 255. 0 means no blue, 255 means full blue.

Definition at line 270 of file SColor.h.

◆ setData()

void saga::video::SColor::setData ( const void *  data,
E_PIXEL_FORMAT  format 
)
inline

set the color by expecting data in the given format

Parameters
datamust point to valid memory containing color information in the given format
formattells the format in which data is available

Definition at line 376 of file SColor.h.

◆ setGreen()

void saga::video::SColor::setGreen ( std::uint32_t  g)
inline

Sets the green component of the Color.

Parameters
gHas to be a value between 0 and 255. 0 means no green, 255 means full green.

Definition at line 265 of file SColor.h.

◆ setRed()

void saga::video::SColor::setRed ( std::uint32_t  r)
inline

Sets the red component of the Color.

Parameters
rHas to be a value between 0 and 255. 0 means no red, 255 means full red.

Definition at line 260 of file SColor.h.

◆ toA1R5G5B5()

std::uint16_t saga::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 274 of file SColor.h.

◆ toGLM()

glm::uvec4 saga::video::SColor::toGLM ( ) const
inline

Definition at line 288 of file SColor.h.

◆ toOpenGLColor()

void saga::video::SColor::toOpenGLColor ( std::uint8_t *  dest) const
inline

Converts color to OpenGL color format.

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

Parameters
destaddress where the 4x8 bit OpenGL color is stored.

Definition at line 280 of file SColor.h.

Member Data Documentation

◆ color

std::uint32_t saga::video::SColor::color

color in A8RGB8 Format

Definition at line 435 of file SColor.h.


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