Gorgon Game Engine
RGBAf Class Reference

Represents a four channel 32 bit float per channel color information. More...

Public Types

typedef float ChannelType
 Data type for each channel. More...
 

Public Member Functions

 RGBAf ()
 Default constructor does not perform initialization. More...
 
 RGBAf (bool)=delete
 Converts from an unsigned int. More...
 
 RGBAf (const RGBA &color)
 Converts a RGBA to RGBAf. More...
 
 RGBAf (const RGBA &color, double alpha)
 Converts a RGBA to RGBAf. More...
 
 RGBAf (const RGBA &color, float alpha)
 Converts a RGBA to RGBAf. More...
 
 RGBAf (double lum, float a=1.0f)
 Constructor that sets all color channels to the given value to create a grayscale color. Alpha is set to 1.0f. More...
 
 RGBAf (float lum, float a=1.0f)
 Constructor that sets all color channels to the given value to create a grayscale color. Alpha is set to 1.0f. More...
 
 RGBAf (float r, float g, float b, float a=1.f)
 Filling constructor. More...
 
 RGBAf (int)=delete
 Converts from an unsigned int. More...
 
 RGBAf (unsigned color)
 Converts from an unsigned int. More...
 
void Blend (const RGBAf &color)
 Blends the given color into this one. More...
 
void Blend (const RGBAf &color, float factor)
 Blends the given color into this one with the given factor that is applied to all channels. More...
 
RGBA Convert () const
 Converts this color to RGBA by clipping the values. More...
 
float Luminance () const
 Returns the luminance of this color as a floating point value between 0 and 1. More...
 
 operator int () const
 Conversion to integer. More...
 
 operator RGBA () const
 Converts this color to RGBA without overflow checking. More...
 
 operator std::string () const
 
bool operator!= (const RGBAf &other) const
 Compares two colors. More...
 
RGBAf operator* (const RGBAf &other) const
 
RGBAfoperator*= (const RGBAf &other)
 
RGBAfoperator= (const int &color)
 Assignment from int. More...
 
RGBAfoperator= (const RGBA &color)
 Assignment from RGBA. More...
 
RGBAfoperator= (const RGBAf &)=default
 Copy assignment. More...
 
RGBAfoperator= (double lum)
 Assignment from float. More...
 
RGBAfoperator= (float lum)
 Assignment from float. More...
 
bool operator== (const RGBAf &other) const
 Compares two colors. More...
 
void Slide (const RGBAf &color, const RGBAf &factor)
 Blends the given color into this one with the given factor that is applied to color and alpha channels separately. More...
 
void Slide (const RGBAf &color, float factor)
 Blends the given color into this one with the given factor that is applied to color and alpha channels separately. More...
 
void Slide (const RGBAf &color, float factor_color, float factor_alpha)
 Blends the given color into this one with the given factor that is applied to color and alpha channels separately. More...
 

Public Attributes

union {
   struct {
      float   A
 Alpha channel. More...
 
      float   B
 Blue channel. More...
 
      float   G
 Green channel. More...
 
      float   R
 Red channel. More...
 
   } 
 
   float   Vector [4]
 Representation of this class as a float vector. More...
 
}; 
 

Detailed Description

Represents a four channel 32 bit float per channel color information.

Member Typedef Documentation

◆ ChannelType

typedef float ChannelType

Data type for each channel.

Constructor & Destructor Documentation

◆ RGBAf() [1/10]

RGBAf ( )

Default constructor does not perform initialization.

◆ RGBAf() [2/10]

RGBAf ( float  r,
float  g,
float  b,
float  a = 1.f 
)

Filling constructor.

◆ RGBAf() [3/10]

RGBAf ( float  lum,
float  a = 1.0f 
)

Constructor that sets all color channels to the given value to create a grayscale color. Alpha is set to 1.0f.

◆ RGBAf() [4/10]

RGBAf ( double  lum,
float  a = 1.0f 
)
explicit

Constructor that sets all color channels to the given value to create a grayscale color. Alpha is set to 1.0f.

◆ RGBAf() [5/10]

RGBAf ( const RGBA color)

Converts a RGBA to RGBAf.

◆ RGBAf() [6/10]

RGBAf ( const RGBA color,
float  alpha 
)

Converts a RGBA to RGBAf.

◆ RGBAf() [7/10]

RGBAf ( const RGBA color,
double  alpha 
)

Converts a RGBA to RGBAf.

◆ RGBAf() [8/10]

RGBAf ( unsigned  color)

Converts from an unsigned int.

◆ RGBAf() [9/10]

RGBAf ( int  )
delete

Converts from an unsigned int.

◆ RGBAf() [10/10]

RGBAf ( bool  )
delete

Converts from an unsigned int.

Member Function Documentation

◆ Blend() [1/2]

void Blend ( const RGBAf color)

Blends the given color into this one.

This operation performs regular alpha blending with the current color being blended over.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ Blend() [2/2]

void Blend ( const RGBAf color,
float  factor 
)

Blends the given color into this one with the given factor that is applied to all channels.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ Convert()

RGBA Convert ( ) const

Converts this color to RGBA by clipping the values.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ Luminance()

float Luminance ( ) const

Returns the luminance of this color as a floating point value between 0 and 1.

The conversion is done to preserve perceived luminance.

References RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator int()

operator int ( ) const
explicit

Conversion to integer.

◆ operator RGBA()

operator RGBA ( ) const
explicit

Converts this color to RGBA without overflow checking.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator std::string()

operator std::string ( ) const

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator!=()

bool operator!= ( const RGBAf other) const

Compares two colors.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator*()

RGBAf operator* ( const RGBAf other) const

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator*=()

RGBAf& operator*= ( const RGBAf other)

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator=() [1/5]

RGBAf& operator= ( const int &  color)

Assignment from int.

◆ operator=() [2/5]

RGBAf& operator= ( const RGBA color)

Assignment from RGBA.

References RGBA::A, RGBAf::A, RGBA::B, RGBAf::B, RGBA::G, RGBAf::G, RGBA::R, and RGBAf::R.

◆ operator=() [3/5]

RGBAf& operator= ( const RGBAf )
default

Copy assignment.

◆ operator=() [4/5]

RGBAf& operator= ( double  lum)

Assignment from float.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator=() [5/5]

RGBAf& operator= ( float  lum)

Assignment from float.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ operator==()

bool operator== ( const RGBAf other) const

Compares two colors.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ Slide() [1/3]

void Slide ( const RGBAf color,
const RGBAf factor 
)

Blends the given color into this one with the given factor that is applied to color and alpha channels separately.

This is not regular alpha blending as source alpha is not used.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ Slide() [2/3]

void Slide ( const RGBAf color,
float  factor 
)

Blends the given color into this one with the given factor that is applied to color and alpha channels separately.

This is not regular alpha blending as source alpha is not used.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

◆ Slide() [3/3]

void Slide ( const RGBAf color,
float  factor_color,
float  factor_alpha 
)

Blends the given color into this one with the given factor that is applied to color and alpha channels separately.

This is not regular alpha blending as source alpha is not used.

References RGBAf::A, RGBAf::B, RGBAf::G, and RGBAf::R.

Member Data Documentation

◆ @18

union { ... }

◆ A

float A

Alpha channel.

◆ B

float B

Blue channel.

◆ G

float G

Green channel.

◆ R

float R

Red channel.

◆ Vector

float Vector[4]

Representation of this class as a float vector.


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