Drag[en]gine Game Engine  1.21
decColor Class Reference

4 Component Color. More...

#include <decColor.h>

Public Member Functions

Management
decColor Normalized () const
 Normalized color with each component clamped to the range of 0 to 1. More...
 
void Normalize ()
 Normalize color. Each component is clamped to the range of 0 to 1. More...
 
decColor Inverted () const
 Inverted color. Each component except alpha is 1-value. More...
 
void Invert ()
 Invert color. Each component except alpha is set to 1-value. More...
 
void SetZero ()
 Set red, green and blue to 0 and alpha to 1. More...
 
void Set (float red, float green, float blue)
 Set values. More...
 
void Set (float red, float green, float blue, float alpha)
 Sets values. More...
 
bool IsEqualTo (const decColor &color, float threshold=COLOR_THRESHOLD) const
 Color is equal component wise to another color with respect to a threshold. More...
 
void ToHSV (float &hue, float &saturation, float &value) const
 Convert to HSV. More...
 
void ToHSL (float &hue, float &saturation, float &lightness) const
 Convert to HSL. More...
 
void ToCMYK (float &cyan, float &magenta, float &yellow, float &black) const
 Convert to CMYK. More...
 
Operators
decColoroperator= (const decColor &color)
 Copy color to this color. More...
 
decColoroperator+= (const decColor &color)
 Add components of another color to this one. More...
 
decColoroperator-= (const decColor &color)
 Subtract components of another color from this color. More...
 
decColoroperator*= (float scalar)
 Multiply components of this color with a value k. More...
 
decColoroperator*= (const decColor &color)
 Multiply components of this color component wise with another color. More...
 
decColoroperator/= (float scalar)
 Divide components of this color by a scalar value. More...
 
decColor operator+ (const decColor &color) const
 Color with the sum of this color with another one. More...
 
decColor operator- (const decColor &color) const
 Color with the difference of this color to another one. More...
 
decColor operator* (float scalar) const
 Color with this color scaled by a scalar. More...
 
decColor operator* (const decColor &color) const
 Color with this color multiplied component wise with another one. More...
 
decColor operator/ (float scalar) const
 Color with this color divided by a scalar. More...
 

Public Attributes

float a
 Alpha Component of color. More...
 
float b
 Blue Component of color. More...
 
float g
 Green Component of color. More...
 
float r
 Red Component of color. More...
 

Constructors and Destructors

 decColor ()
 Create color initialized to (0,0,0,1). More...
 
 decColor (float red, float green, float blue)
 Create color with initial values. More...
 
 decColor (float red, float green, float blue, float alpha)
 Create color with the given values. More...
 
 decColor (const decColor &copy)
 Creates copy of a color. More...
 
 decColor (const decColor &copy, float alpha)
 Creates copy of a color with different alpha value. More...
 
static decColor CreateHSV (float hue, float saturation, float value)
 Create color from HSV. More...
 
static decColor CreateHSL (float hue, float saturation, float lightness)
 Create color from HSL. More...
 
static decColor CreateCMYK (float cyan, float magenta, float yellow, float black)
 Create color from CMYK. More...
 

Detailed Description

4 Component Color.

RGBA style color in decimal range. The value of 0 indicates no luminance in that color and 1 indicates full luminance. The color also contains an alpha component where 0 indicates completly transparent and 1 indicates completly opaque.

Constructor & Destructor Documentation

◆ decColor() [1/5]

decColor::decColor ( )

Create color initialized to (0,0,0,1).

◆ decColor() [2/5]

decColor::decColor ( float  red,
float  green,
float  blue 
)

Create color with initial values.

◆ decColor() [3/5]

decColor::decColor ( float  red,
float  green,
float  blue,
float  alpha 
)

Create color with the given values.

◆ decColor() [4/5]

decColor::decColor ( const decColor copy)

Creates copy of a color.

◆ decColor() [5/5]

decColor::decColor ( const decColor copy,
float  alpha 
)

Creates copy of a color with different alpha value.

Member Function Documentation

◆ CreateCMYK()

static decColor decColor::CreateCMYK ( float  cyan,
float  magenta,
float  yellow,
float  black 
)
static

Create color from CMYK.

Version
1.8
Parameters
[in]cyanCyan in the range from 0 to 1. Value is clamped.
[in]magentaMagenta in the range from 0 to 1. Value is clamped.
[in]yellowYellow in the range from 0 to 1. Value is clamped.
[in]blackBlack in the range from 0 to 1. Value is clamped.

◆ CreateHSL()

static decColor decColor::CreateHSL ( float  hue,
float  saturation,
float  lightness 
)
static

Create color from HSL.

Version
1.8
Parameters
[in]hueHue in the range from 0 (0 degrees) to 1 (360 degrees). Values outside this range are normalized hence -0.2 is used as 0.8 for the calculation.
[in]saturationSaturation in the range from 0 to 1. Value is clamped.
[in]lightnessLightness in the range from 0 to 1. Value is clamped.

◆ CreateHSV()

static decColor decColor::CreateHSV ( float  hue,
float  saturation,
float  value 
)
static

Create color from HSV.

Version
1.8
Parameters
[in]hueHue in the range from 0 (0 degrees) to 1 (360 degrees). Values outside this range are normalized hence -0.2 is used as 0.8 for the calculation.
[in]saturationSaturation in the range from 0 to 1. Value is clamped.
[in]valueValue in the range from 0 to 1. Value is clamped.

◆ Invert()

void decColor::Invert ( )

Invert color. Each component except alpha is set to 1-value.

◆ Inverted()

decColor decColor::Inverted ( ) const

Inverted color. Each component except alpha is 1-value.

◆ IsEqualTo()

bool decColor::IsEqualTo ( const decColor color,
float  threshold = COLOR_THRESHOLD 
) const

Color is equal component wise to another color with respect to a threshold.

◆ Normalize()

void decColor::Normalize ( )

Normalize color. Each component is clamped to the range of 0 to 1.

◆ Normalized()

decColor decColor::Normalized ( ) const

Normalized color with each component clamped to the range of 0 to 1.

◆ operator*() [1/2]

decColor decColor::operator* ( const decColor color) const

Color with this color multiplied component wise with another one.

◆ operator*() [2/2]

decColor decColor::operator* ( float  scalar) const

Color with this color scaled by a scalar.

◆ operator*=() [1/2]

decColor& decColor::operator*= ( const decColor color)

Multiply components of this color component wise with another color.

◆ operator*=() [2/2]

decColor& decColor::operator*= ( float  scalar)

Multiply components of this color with a value k.

◆ operator+()

decColor decColor::operator+ ( const decColor color) const

Color with the sum of this color with another one.

◆ operator+=()

decColor& decColor::operator+= ( const decColor color)

Add components of another color to this one.

◆ operator-()

decColor decColor::operator- ( const decColor color) const

Color with the difference of this color to another one.

◆ operator-=()

decColor& decColor::operator-= ( const decColor color)

Subtract components of another color from this color.

◆ operator/()

decColor decColor::operator/ ( float  scalar) const

Color with this color divided by a scalar.

Exceptions
deeDivisionByZeroScalar is 0.

◆ operator/=()

decColor& decColor::operator/= ( float  scalar)

Divide components of this color by a scalar value.

Exceptions
deeDivisionByZeroScalar is 0.

◆ operator=()

decColor& decColor::operator= ( const decColor color)

Copy color to this color.

◆ Set() [1/2]

void decColor::Set ( float  red,
float  green,
float  blue 
)

Set values.

◆ Set() [2/2]

void decColor::Set ( float  red,
float  green,
float  blue,
float  alpha 
)

Sets values.

◆ SetZero()

void decColor::SetZero ( )

Set red, green and blue to 0 and alpha to 1.

◆ ToCMYK()

void decColor::ToCMYK ( float &  cyan,
float &  magenta,
float &  yellow,
float &  black 
) const

Convert to CMYK.

Version
1.8
Parameters
[out]cyanCyan in the range from 0 to 1.
[out]magentaMagenta in the range from 0 to 1.
[out]yellowYellow in the range from 0 to 1.
[out]blackBlack in the range from 0 to 1.

◆ ToHSL()

void decColor::ToHSL ( float &  hue,
float &  saturation,
float &  lightness 
) const

Convert to HSL.

Version
1.8
Parameters
[out]hueHue in the range from 0 (0 degrees) to 1 (360 degrees).
[out]saturationSaturation in the range from 0 to 1.
[out]lightnessLightness in the range from 0 to 1.

◆ ToHSV()

void decColor::ToHSV ( float &  hue,
float &  saturation,
float &  value 
) const

Convert to HSV.

Version
1.8
Parameters
[out]hueHue in the range from 0 (0 degrees) to 1 (360 degrees).
[out]saturationSaturation in the range from 0 to 1.
[out]valueValue in the range from 0 to 1.

Member Data Documentation

◆ a

float decColor::a

Alpha Component of color.

◆ b

float decColor::b

Blue Component of color.

◆ g

float decColor::g

Green Component of color.

◆ r

float decColor::r

Red Component of color.


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