Drag[en]gine Game Engine  1.0
decColorMatrix Class Reference

5x4 component color matrix in row major order. More...

#include <decColorMatrix.h>

Public Member Functions

Constructors and Destructors
 decColorMatrix ()
 Create color matrix initialized to identity. More...
 
 decColorMatrix (const decColorMatrix &m)
 Create copy of a color matrix. More...
 
Management
void SetIdentity ()
 Set identity color matrix. More...
 
void SetTranslation (float red, float green, float blue, float alpha)
 Set translation color matrix. More...
 
void SetTranslation (const decColor &color)
 Set translation color matrix. More...
 
void SetScaling (float sred, float sgreen, float sblue, float salpha)
 Set scaling color matrix. More...
 
void SetScaling (const decColor &color)
 Set scaling color matrix. More...
 
void SetST (const decColor &scale, const decColor &translate)
 Set scaling then translation color matrix. More...
 
void SetFrom (const decColor &red, const decColor &green, const decColor &blue, const decColor &alpha, const decColor &white)
 Set color matrix transformation base. More...
 
void SetBrightness (float brightness)
 Set brightness adjustment matrix. More...
 
void SetBrightness (float red, float green, float blue)
 Set brightness adjustment matrix. More...
 
void SetBrightness (const decColor &brightness)
 Set brightness adjustment matrix. More...
 
void SetContrast (float contrast)
 Set contrast adjustment matrix. More...
 
void SetContrast (float red, float green, float blue)
 Set contrast adjustment matrix. More...
 
void SetContrast (const decColor &contrast)
 Set contrast adjustment matrix. More...
 
void SetSaturation (float saturation)
 Set saturation adjustment matrix. More...
 
void SetSaturation (float red, float green, float blue)
 Set saturation adjustment matrix. More...
 
void SetSaturation (const decColor &saturation)
 Set saturation adjustment matrix. More...
 
void SetColorInversion ()
 Set color inversion matrix. More...
 
float Determinant () const
 Determinant of the color matrix. More...
 
decColorMatrix Invert () const
 Inverse of color matrix if the inverse is possible. More...
 
decColor GetRedBase () const
 Red color base. More...
 
decColor GetGreenBase () const
 Green color base. More...
 
decColor GetBlueBase () const
 Blue color base. More...
 
decColor GetAlphaBase () const
 Alpha color base. More...
 
decColor GetWhiteBase () const
 White color base. More...
 
void SetRedBase (const decColor &color)
 Set red color base. More...
 
void SetGreenBase (const decColor &color)
 Set green color base. More...
 
void SetBlueBase (const decColor &color)
 Set blue color base. More...
 
void SetAlphaBase (const decColor &color)
 Set alpha color base. More...
 
void SetWhiteBase (const decColor &color)
 Set white color base. More...
 
decColor Transform (const decColor &color) const
 Transform color by this matrix. More...
 
decColor Transform (float red, float green, float blue) const
 Transform color by this matrix. More...
 
decColor Transform (float red, float green, float blue, float alpha) const
 Transform color by this matrix. More...
 
decColor TransformColor (const decColor &color) const
 Transform only color component of color by this matrix. More...
 
bool IsEqualTo (const decColorMatrix &matrix, float threshold=VECTOR_THRESHOLD) const
 Matrix is cell wise equal to another one in respect to a threshold. More...
 
Operators
decColorMatrixoperator= (const decColorMatrix &matrix)
 Copy another matrix to this matrix. More...
 
decColorMatrixoperator+= (const decColorMatrix &matrix)
 Cell-wise add another matrix this this. More...
 
decColorMatrixoperator-= (const decColorMatrix &matrix)
 Cell-wise subtract another matrix from this matrix. More...
 
decColorMatrixoperator*= (float scalar)
 Cell-wise multiply matrix with a scalar. More...
 
decColorMatrixoperator/= (float scalar)
 Cell-wise divide matrix by a scalar. More...
 
decColorMatrixoperator*= (const decColorMatrix &matrix)
 Matrix-multiply this matrix with another matrix. More...
 
decColorMatrix operator+ (const decColorMatrix &matrix) const
 Cell-wise addition this matrix and another matrix. More...
 
decColorMatrix operator- (const decColorMatrix &matrix) const
 Cell-wise subtraction of another matrix from this matrix. More...
 
decColorMatrix operator* (float scalar) const
 Cell-wise multiplication of matrix with a scalar. More...
 
decColorMatrix operator/ (float scalar) const
 Cell-wise division of matrix by a scalar. More...
 
decColorMatrix operator* (const decColorMatrix &matrix) const
 Matrix-multiplication of this matrix with another matrix. More...
 
decColor operator* (const decColor &color) const
 Transform color by matrix. More...
 

Static Public Member Functions

Matrix Creation
static decColorMatrix CreateIdentity ()
 Create identity color matrix. More...
 
static decColorMatrix CreateTranslation (float red, float green, float blue, float alpha)
 Create color translation matrix. More...
 
static decColorMatrix CreateTranslation (const decColor &color)
 Create color translation matrix. More...
 
static decColorMatrix CreateScaling (float sred, float sgreen, float sblue, float salpha)
 Create color scaling matrix. More...
 
static decColorMatrix CreateScaling (const decColor &color)
 Create color scaling matrix. More...
 
static decColorMatrix CreateST (const decColor &scale, const decColor &translate)
 Create scaling then translation color matrix. More...
 
static decColorMatrix CreateFrom (const decColor &red, const decColor &green, const decColor &blue, const decColor &alpha, const decColor &white)
 Create color matrix with colors as transformation base. More...
 
static decColorMatrix CreateBrightness (float brightness)
 Create brightness adjustment matrix. More...
 
static decColorMatrix CreateBrightness (float red, float green, float blue)
 Create brightness adjustment matrix. More...
 
static decColorMatrix CreateBrightness (const decColor &brightness)
 Create brightness adjustment matrix. More...
 
static decColorMatrix CreateContrast (float contrast)
 Create contrast adjustment matrix. More...
 
static decColorMatrix CreateContrast (float red, float green, float blue)
 Create contrast adjustment matrix. More...
 
static decColorMatrix CreateContrast (const decColor &contrast)
 Create contrast adjustment matrix. More...
 
static decColorMatrix CreateSaturation (float saturation)
 Create saturation adjustment matrix. More...
 
static decColorMatrix CreateSaturation (float red, float green, float blue)
 Create saturation adjustment matrix. More...
 
static decColorMatrix CreateSaturation (const decColor &saturation)
 Create saturation adjustment matrix. More...
 
static decColorMatrix CreateColorInversion ()
 Create color inversion matrix. More...
 

Public Attributes

float a11
 
float a12
 
float a13
 
float a14
 
float a15
 
float a21
 
float a22
 
float a23
 
float a24
 
float a25
 
float a31
 
float a32
 
float a33
 
float a34
 
float a35
 
float a41
 
float a42
 
float a43
 
float a44
 
float a45
 

Detailed Description

5x4 component color matrix in row major order.

The colons are (1 to 5): red, green, blue, alpha and white. The rows are (1 to 4): red, green, blue and alpha. Color transformation has to be done in linear color space. With gamma corrected colors certain transformation functions can yield wrong results.

Author
Pl├╝ss Roland
Version
1.0
Date
2015

Constructor & Destructor Documentation

◆ decColorMatrix() [1/2]

decColorMatrix::decColorMatrix ( )

Create color matrix initialized to identity.

◆ decColorMatrix() [2/2]

decColorMatrix::decColorMatrix ( const decColorMatrix m)

Create copy of a color matrix.

Member Function Documentation

◆ CreateBrightness() [1/3]

static decColorMatrix decColorMatrix::CreateBrightness ( float  brightness)
static

Create brightness adjustment matrix.

Brightness can be positive or negative.

◆ CreateBrightness() [2/3]

static decColorMatrix decColorMatrix::CreateBrightness ( float  red,
float  green,
float  blue 
)
static

Create brightness adjustment matrix.

Brightness can be positive or negative.

◆ CreateBrightness() [3/3]

static decColorMatrix decColorMatrix::CreateBrightness ( const decColor brightness)
static

Create brightness adjustment matrix.

Brightness can be positive or negative.

◆ CreateColorInversion()

static decColorMatrix decColorMatrix::CreateColorInversion ( )
static

Create color inversion matrix.

◆ CreateContrast() [1/3]

static decColorMatrix decColorMatrix::CreateContrast ( float  contrast)
static

Create contrast adjustment matrix.

Contrast can be positive or negative.

◆ CreateContrast() [2/3]

static decColorMatrix decColorMatrix::CreateContrast ( float  red,
float  green,
float  blue 
)
static

Create contrast adjustment matrix.

Contrast can be positive or negative.

◆ CreateContrast() [3/3]

static decColorMatrix decColorMatrix::CreateContrast ( const decColor contrast)
static

Create contrast adjustment matrix.

Contrast can be positive or negative.

◆ CreateFrom()

static decColorMatrix decColorMatrix::CreateFrom ( const decColor red,
const decColor green,
const decColor blue,
const decColor alpha,
const decColor white 
)
static

Create color matrix with colors as transformation base.

The parameters fill the colons from 1 to 5 in the appropriate order..

◆ CreateIdentity()

static decColorMatrix decColorMatrix::CreateIdentity ( )
static

Create identity color matrix.

◆ CreateSaturation() [1/3]

static decColorMatrix decColorMatrix::CreateSaturation ( float  saturation)
static

Create saturation adjustment matrix.

Saturation can be positive or negative.

◆ CreateSaturation() [2/3]

static decColorMatrix decColorMatrix::CreateSaturation ( float  red,
float  green,
float  blue 
)
static

Create saturation adjustment matrix.

Saturation can be positive or negative.

◆ CreateSaturation() [3/3]

static decColorMatrix decColorMatrix::CreateSaturation ( const decColor saturation)
static

Create saturation adjustment matrix.

Saturation can be positive or negative.

◆ CreateScaling() [1/2]

static decColorMatrix decColorMatrix::CreateScaling ( float  sred,
float  sgreen,
float  sblue,
float  salpha 
)
static

Create color scaling matrix.

◆ CreateScaling() [2/2]

static decColorMatrix decColorMatrix::CreateScaling ( const decColor color)
static

Create color scaling matrix.

◆ CreateST()

static decColorMatrix decColorMatrix::CreateST ( const decColor scale,
const decColor translate 
)
static

Create scaling then translation color matrix.

◆ CreateTranslation() [1/2]

static decColorMatrix decColorMatrix::CreateTranslation ( float  red,
float  green,
float  blue,
float  alpha 
)
static

Create color translation matrix.

◆ CreateTranslation() [2/2]

static decColorMatrix decColorMatrix::CreateTranslation ( const decColor color)
static

Create color translation matrix.

◆ Determinant()

float decColorMatrix::Determinant ( ) const

Determinant of the color matrix.

Mathematically this only works on a 5x5 matrix. The color matrix is first expanded with an identity line at the bottom to become a 5x5 matrix. From this matrix the determinant is calculated from.

◆ GetAlphaBase()

decColor decColorMatrix::GetAlphaBase ( ) const

Alpha color base.

◆ GetBlueBase()

decColor decColorMatrix::GetBlueBase ( ) const

Blue color base.

◆ GetGreenBase()

decColor decColorMatrix::GetGreenBase ( ) const

Green color base.

◆ GetRedBase()

decColor decColorMatrix::GetRedBase ( ) const

Red color base.

◆ GetWhiteBase()

decColor decColorMatrix::GetWhiteBase ( ) const

White color base.

◆ Invert()

decColorMatrix decColorMatrix::Invert ( ) const

Inverse of color matrix if the inverse is possible.

Mathematically this only works for a 5x5 matrix. The color matrix is expanded with an identity line to become a 5x5 matrix. Form this matrix the inverse is calculated and the 5x4 part returned.

◆ IsEqualTo()

bool decColorMatrix::IsEqualTo ( const decColorMatrix matrix,
float  threshold = VECTOR_THRESHOLD 
) const

Matrix is cell wise equal to another one in respect to a threshold.

◆ operator*() [1/3]

decColorMatrix decColorMatrix::operator* ( float  scalar) const

Cell-wise multiplication of matrix with a scalar.

◆ operator*() [2/3]

decColorMatrix decColorMatrix::operator* ( const decColorMatrix matrix) const

Matrix-multiplication of this matrix with another matrix.

Mathematically this results in a 5x5 matrix. The last row is discarded.

◆ operator*() [3/3]

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

Transform color by matrix.

◆ operator*=() [1/2]

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

Cell-wise multiply matrix with a scalar.

◆ operator*=() [2/2]

decColorMatrix& decColorMatrix::operator*= ( const decColorMatrix matrix)

Matrix-multiply this matrix with another matrix.

Mathematically this results in a 5x5 matrix. The last row is discarded.

◆ operator+()

decColorMatrix decColorMatrix::operator+ ( const decColorMatrix matrix) const

Cell-wise addition this matrix and another matrix.

◆ operator+=()

decColorMatrix& decColorMatrix::operator+= ( const decColorMatrix matrix)

Cell-wise add another matrix this this.

◆ operator-()

decColorMatrix decColorMatrix::operator- ( const decColorMatrix matrix) const

Cell-wise subtraction of another matrix from this matrix.

◆ operator-=()

decColorMatrix& decColorMatrix::operator-= ( const decColorMatrix matrix)

Cell-wise subtract another matrix from this matrix.

◆ operator/()

decColorMatrix decColorMatrix::operator/ ( float  scalar) const

Cell-wise division of matrix by a scalar.

Exceptions
deeDivisionByZeroscalar is 0.

◆ operator/=()

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

Cell-wise divide matrix by a scalar.

Exceptions
deeDivisionByZeroscalar is 0.

◆ operator=()

decColorMatrix& decColorMatrix::operator= ( const decColorMatrix matrix)

Copy another matrix to this matrix.

◆ SetAlphaBase()

void decColorMatrix::SetAlphaBase ( const decColor color)

Set alpha color base.

◆ SetBlueBase()

void decColorMatrix::SetBlueBase ( const decColor color)

Set blue color base.

◆ SetBrightness() [1/3]

void decColorMatrix::SetBrightness ( float  brightness)

Set brightness adjustment matrix.

Brightness can be positive or negative.

◆ SetBrightness() [2/3]

void decColorMatrix::SetBrightness ( float  red,
float  green,
float  blue 
)

Set brightness adjustment matrix.

Brightness can be positive or negative.

◆ SetBrightness() [3/3]

void decColorMatrix::SetBrightness ( const decColor brightness)

Set brightness adjustment matrix.

Brightness can be positive or negative.

◆ SetColorInversion()

void decColorMatrix::SetColorInversion ( )

Set color inversion matrix.

◆ SetContrast() [1/3]

void decColorMatrix::SetContrast ( float  contrast)

Set contrast adjustment matrix.

Contrast can be positive or negative.

◆ SetContrast() [2/3]

void decColorMatrix::SetContrast ( float  red,
float  green,
float  blue 
)

Set contrast adjustment matrix.

Contrast can be positive or negative.

◆ SetContrast() [3/3]

void decColorMatrix::SetContrast ( const decColor contrast)

Set contrast adjustment matrix.

Contrast can be positive or negative.

◆ SetFrom()

void decColorMatrix::SetFrom ( const decColor red,
const decColor green,
const decColor blue,
const decColor alpha,
const decColor white 
)

Set color matrix transformation base.

The parameters fill the colons from 1 to 5 in the appropriate order..

◆ SetGreenBase()

void decColorMatrix::SetGreenBase ( const decColor color)

Set green color base.

◆ SetIdentity()

void decColorMatrix::SetIdentity ( )

Set identity color matrix.

◆ SetRedBase()

void decColorMatrix::SetRedBase ( const decColor color)

Set red color base.

◆ SetSaturation() [1/3]

void decColorMatrix::SetSaturation ( float  saturation)

Set saturation adjustment matrix.

Saturation can be positive or negative.

◆ SetSaturation() [2/3]

void decColorMatrix::SetSaturation ( float  red,
float  green,
float  blue 
)

Set saturation adjustment matrix.

Saturation can be positive or negative.

◆ SetSaturation() [3/3]

void decColorMatrix::SetSaturation ( const decColor saturation)

Set saturation adjustment matrix.

Saturation can be positive or negative.

◆ SetScaling() [1/2]

void decColorMatrix::SetScaling ( float  sred,
float  sgreen,
float  sblue,
float  salpha 
)

Set scaling color matrix.

◆ SetScaling() [2/2]

void decColorMatrix::SetScaling ( const decColor color)

Set scaling color matrix.

◆ SetST()

void decColorMatrix::SetST ( const decColor scale,
const decColor translate 
)

Set scaling then translation color matrix.

◆ SetTranslation() [1/2]

void decColorMatrix::SetTranslation ( float  red,
float  green,
float  blue,
float  alpha 
)

Set translation color matrix.

◆ SetTranslation() [2/2]

void decColorMatrix::SetTranslation ( const decColor color)

Set translation color matrix.

◆ SetWhiteBase()

void decColorMatrix::SetWhiteBase ( const decColor color)

Set white color base.

◆ Transform() [1/3]

decColor decColorMatrix::Transform ( const decColor color) const

Transform color by this matrix.

◆ Transform() [2/3]

decColor decColorMatrix::Transform ( float  red,
float  green,
float  blue 
) const

Transform color by this matrix.

◆ Transform() [3/3]

decColor decColorMatrix::Transform ( float  red,
float  green,
float  blue,
float  alpha 
) const

Transform color by this matrix.

◆ TransformColor()

decColor decColorMatrix::TransformColor ( const decColor color) const

Transform only color component of color by this matrix.

color alpha is assumed to be one. Result alpha is set to 1.

Member Data Documentation

◆ a11

float decColorMatrix::a11

◆ a12

float decColorMatrix::a12

◆ a13

float decColorMatrix::a13

◆ a14

float decColorMatrix::a14

◆ a15

float decColorMatrix::a15

◆ a21

float decColorMatrix::a21

◆ a22

float decColorMatrix::a22

◆ a23

float decColorMatrix::a23

◆ a24

float decColorMatrix::a24

◆ a25

float decColorMatrix::a25

◆ a31

float decColorMatrix::a31

◆ a32

float decColorMatrix::a32

◆ a33

float decColorMatrix::a33

◆ a34

float decColorMatrix::a34

◆ a35

float decColorMatrix::a35

◆ a41

float decColorMatrix::a41

◆ a42

float decColorMatrix::a42

◆ a43

float decColorMatrix::a43

◆ a44

float decColorMatrix::a44

◆ a45

float decColorMatrix::a45

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