Open CASCADE Technology  7.6.0
Public Member Functions | Static Public Member Functions

Quantity_ColorRGBA Class Reference

The pair of Quantity_Color and Alpha component (1.0 opaque, 0.0 transparent). More...

#include <Quantity_ColorRGBA.hxx>

Public Member Functions

 Quantity_ColorRGBA ()
 Creates a color with the default value. More...
 
 Quantity_ColorRGBA (const Quantity_Color &theRgb)
 Creates the color with specified RGB value. More...
 
 Quantity_ColorRGBA (const Quantity_Color &theRgb, float theAlpha)
 Creates the color with specified RGBA values. More...
 
 Quantity_ColorRGBA (const NCollection_Vec4< float > &theRgba)
 Creates the color from RGBA vector. More...
 
 Quantity_ColorRGBA (float theRed, float theGreen, float theBlue, float theAlpha)
 Creates the color from RGBA values. More...
 
void SetValues (float theRed, float theGreen, float theBlue, float theAlpha)
 Assign new values to the color. More...
 
const Quantity_ColorGetRGB () const
 Return RGB color value. More...
 
Quantity_ColorChangeRGB ()
 Modify RGB color components without affecting alpha value. More...
 
void SetRGB (const Quantity_Color &theRgb)
 Assign RGB color components without affecting alpha value. More...
 
Standard_ShortReal Alpha () const
 Return alpha value (1.0 means opaque, 0.0 means fully transparent). More...
 
void SetAlpha (const Standard_ShortReal theAlpha)
 Assign the alpha value. More...
 
 operator const NCollection_Vec4< float > & () const
 Return the color as vector of 4 float elements. More...
 
bool IsDifferent (const Quantity_ColorRGBA &theOther) const
 Returns true if the distance between colors is greater than Epsilon(). More...
 
bool operator!= (const Quantity_ColorRGBA &theOther) const
 Returns true if the distance between colors is greater than Epsilon(). More...
 
bool IsEqual (const Quantity_ColorRGBA &theOther) const
 Two colors are considered to be equal if their distance is no greater than Epsilon(). More...
 
bool operator== (const Quantity_ColorRGBA &theOther) const
 Two colors are considered to be equal if their distance is no greater than Epsilon(). More...
 
void DumpJson (Standard_OStream &theOStream, Standard_Integer theDepth=-1) const
 Dumps the content of me into the stream. More...
 
Standard_Boolean InitFromJson (const Standard_SStream &theSStream, Standard_Integer &theStreamPos)
 Inits the content of me from the stream. More...
 

Static Public Member Functions

static Standard_Boolean ColorFromName (const Standard_CString theColorNameString, Quantity_ColorRGBA &theColor)
 Finds color from predefined names. For example, the name of the color which corresponds to "BLACK" is Quantity_NOC_BLACK. An alpha component is set to 1.0. More...
 
static bool ColorFromHex (const char *const theHexColorString, Quantity_ColorRGBA &theColor, const bool theAlphaComponentIsOff=false)
 Parses the string as a hex color (like "#FF0" for short sRGB color, "#FF0F" for short sRGBA color, "#FFFF00" for RGB color, or "#FFFF00FF" for RGBA color) More...
 
static TCollection_AsciiString ColorToHex (const Quantity_ColorRGBA &theColor, const bool theToPrefixHash=true)
 Returns hex sRGBA string in format "#RRGGBBAA". More...
 
static NCollection_Vec4< float > Convert_LinearRGB_To_sRGB (const NCollection_Vec4< float > &theRGB)
 Convert linear RGB components into sRGB using OpenGL specs formula. More...
 
static NCollection_Vec4< float > Convert_sRGB_To_LinearRGB (const NCollection_Vec4< float > &theRGB)
 Convert sRGB components into linear RGB using OpenGL specs formula. More...
 

Detailed Description

The pair of Quantity_Color and Alpha component (1.0 opaque, 0.0 transparent).

Constructor & Destructor Documentation

◆ Quantity_ColorRGBA() [1/5]

Quantity_ColorRGBA::Quantity_ColorRGBA ( )
inline

Creates a color with the default value.

◆ Quantity_ColorRGBA() [2/5]

Quantity_ColorRGBA::Quantity_ColorRGBA ( const Quantity_Color theRgb)
inlineexplicit

Creates the color with specified RGB value.

◆ Quantity_ColorRGBA() [3/5]

Quantity_ColorRGBA::Quantity_ColorRGBA ( const Quantity_Color theRgb,
float  theAlpha 
)
inline

Creates the color with specified RGBA values.

◆ Quantity_ColorRGBA() [4/5]

Quantity_ColorRGBA::Quantity_ColorRGBA ( const NCollection_Vec4< float > &  theRgba)
inlineexplicit

Creates the color from RGBA vector.

◆ Quantity_ColorRGBA() [5/5]

Quantity_ColorRGBA::Quantity_ColorRGBA ( float  theRed,
float  theGreen,
float  theBlue,
float  theAlpha 
)
inline

Creates the color from RGBA values.

Member Function Documentation

◆ Alpha()

Standard_ShortReal Quantity_ColorRGBA::Alpha ( ) const
inline

Return alpha value (1.0 means opaque, 0.0 means fully transparent).

◆ ChangeRGB()

Quantity_Color& Quantity_ColorRGBA::ChangeRGB ( )
inline

Modify RGB color components without affecting alpha value.

◆ ColorFromHex()

static bool Quantity_ColorRGBA::ColorFromHex ( const char *const  theHexColorString,
Quantity_ColorRGBA theColor,
const bool  theAlphaComponentIsOff = false 
)
static

Parses the string as a hex color (like "#FF0" for short sRGB color, "#FF0F" for short sRGBA color, "#FFFF00" for RGB color, or "#FFFF00FF" for RGBA color)

Parameters
theHexColorStringthe string to be parsed
theColora color that is a result of parsing
theAlphaComponentIsOffthe flag that indicates if a color alpha component is presented in the input string (false) or not (true)
Returns
true if parsing was successful, or false otherwise

◆ ColorFromName()

static Standard_Boolean Quantity_ColorRGBA::ColorFromName ( const Standard_CString  theColorNameString,
Quantity_ColorRGBA theColor 
)
inlinestatic

Finds color from predefined names. For example, the name of the color which corresponds to "BLACK" is Quantity_NOC_BLACK. An alpha component is set to 1.0.

Parameters
theColorNameStringthe color name
theColora found color
Returns
false if the color name is unknown, or true if the search by color name was successful

◆ ColorToHex()

static TCollection_AsciiString Quantity_ColorRGBA::ColorToHex ( const Quantity_ColorRGBA theColor,
const bool  theToPrefixHash = true 
)
inlinestatic

Returns hex sRGBA string in format "#RRGGBBAA".

◆ Convert_LinearRGB_To_sRGB()

static NCollection_Vec4<float> Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ( const NCollection_Vec4< float > &  theRGB)
inlinestatic

Convert linear RGB components into sRGB using OpenGL specs formula.

◆ Convert_sRGB_To_LinearRGB()

static NCollection_Vec4<float> Quantity_ColorRGBA::Convert_sRGB_To_LinearRGB ( const NCollection_Vec4< float > &  theRGB)
inlinestatic

Convert sRGB components into linear RGB using OpenGL specs formula.

◆ DumpJson()

void Quantity_ColorRGBA::DumpJson ( Standard_OStream theOStream,
Standard_Integer  theDepth = -1 
) const

Dumps the content of me into the stream.

◆ GetRGB()

const Quantity_Color& Quantity_ColorRGBA::GetRGB ( ) const
inline

Return RGB color value.

◆ InitFromJson()

Standard_Boolean Quantity_ColorRGBA::InitFromJson ( const Standard_SStream theSStream,
Standard_Integer theStreamPos 
)

Inits the content of me from the stream.

◆ IsDifferent()

bool Quantity_ColorRGBA::IsDifferent ( const Quantity_ColorRGBA theOther) const
inline

Returns true if the distance between colors is greater than Epsilon().

◆ IsEqual()

bool Quantity_ColorRGBA::IsEqual ( const Quantity_ColorRGBA theOther) const
inline

Two colors are considered to be equal if their distance is no greater than Epsilon().

◆ operator const NCollection_Vec4< float > &()

Quantity_ColorRGBA::operator const NCollection_Vec4< float > & ( ) const
inline

Return the color as vector of 4 float elements.

◆ operator!=()

bool Quantity_ColorRGBA::operator!= ( const Quantity_ColorRGBA theOther) const
inline

Returns true if the distance between colors is greater than Epsilon().

◆ operator==()

bool Quantity_ColorRGBA::operator== ( const Quantity_ColorRGBA theOther) const
inline

Two colors are considered to be equal if their distance is no greater than Epsilon().

◆ SetAlpha()

void Quantity_ColorRGBA::SetAlpha ( const Standard_ShortReal  theAlpha)
inline

Assign the alpha value.

◆ SetRGB()

void Quantity_ColorRGBA::SetRGB ( const Quantity_Color theRgb)
inline

Assign RGB color components without affecting alpha value.

◆ SetValues()

void Quantity_ColorRGBA::SetValues ( float  theRed,
float  theGreen,
float  theBlue,
float  theAlpha 
)
inline

Assign new values to the color.


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