Open CASCADE Technology  6.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions
Quantity_Color Class Reference

This class allows the definition of a colour.
The names of the colours are from the X11 specification.
color object may be used for numerous applicative purposes.
A color is defined by:
More...

#include <Quantity_Color.hxx>

Public Member Functions

 Quantity_Color ()
 
 Creates a colour with the default value of <br>
   Colour name : YELLOW <br>


More...

 
 Quantity_Color (const Quantity_NameOfColor AName)
 
 Creates the colour <AName>. <br>


More...

 
 Quantity_Color (const Quantity_Parameter R1, const Quantity_Parameter R2, const Quantity_Parameter R3, const Quantity_TypeOfColor AType)
 
 Creates a colour according to the definition system <br>
   TypeOfColor. <br>
   TOC_RGB : <R1> the value of red between 0. and 1. <br>
      <R2> the value of green between 0. and 1. <br>
      <R3> the value of blue between 0. and 1. <br>


TOC_HLS : <R1> is the hue angle in degrees, 0. being red
<R2> is the lightness between 0. and 1.
<R3> is the saturation between 0. and 1.

More...

 
Quantity_ColorAssign (const Quantity_Color &Other)
 Updates the colour <me> from the definition of the
colour <Other>.
More...
 
Quantity_Coloroperator= (const Quantity_Color &Other)
 
void ChangeContrast (const Quantity_Rate ADelta)
 Increases or decreases the contrast by <ADelta>.
<ADelta> is a percentage. Any value greater than zero
will increase the contrast.
The variation is expressed as a percentage of the
current value.
It is a variation of the saturation.
More...
 
void ChangeIntensity (const Quantity_Rate ADelta)
 Increases or decreases the intensity by <ADelta>.
<ADelta> is a percentage. Any value greater than zero
will increase the intensity.
The variation is expressed as a percentage of the
current value.
It is a variation of the lightness.
More...
 
void SetValues (const Quantity_NameOfColor AName)
 Updates the colour <me> from the definition of the
colour <AName>.
More...
 
void SetValues (const Quantity_Parameter R1, const Quantity_Parameter R2, const Quantity_Parameter R3, const Quantity_TypeOfColor AType)
 
 Updates a colour according to the mode specified by <br>
   TypeOfColor <br>
   TOC_RGB : <R1> the value of red between 0. and 1. <br>
      <R2> the value of green between 0. and 1. <br>
      <R3> the value of blue between 0. and 1. <br>


TOC_HLS : <R1> is the hue angle in degrees, 0. being red
<R2> is the lightness between 0. and 1.
<R3> is the saturation between 0. and 1.

More...

 
void Delta (const Quantity_Color &AColor, Quantity_Parameter &DC, Quantity_Parameter &DI) const
 Returns the percentage change of contrast and intensity
between <me> and <AColor>.
<DC> and <DI> are percentages, either positive or negative.
The calculation is with respect to the current value of <me>
If <DC> is positive then <me> is more contrasty.
If <DI> is positive then <me> is more intense.
More...
 
Standard_Real Distance (const Quantity_Color &AColor) const
 Returns the distance between two colours. It's a
value between 0 and the square root of 3
(the black/white distance)
More...
 
Standard_Real SquareDistance (const Quantity_Color &AColor) const
 Returns the square of distance between two colours.
More...
 
Quantity_Parameter Blue () const
 Returns the Blue component (quantity of blue) of the
color <me>.
More...
 
Quantity_Parameter Green () const
 Returns the Green component (quantity of green) of the
color <me>.
More...
 
Quantity_Parameter Hue () const
 Returns the Hue component (hue angle) of the
color <me>.
More...
 
Standard_Boolean IsDifferent (const Quantity_Color &Other) const
 Returns Standard_True if the distance between <me> and
<Other> is greater than Epsilon ().
More...
 
Standard_Boolean operator!= (const Quantity_Color &Other) const
 
Standard_Boolean IsEqual (const Quantity_Color &Other) const
 Returns true if the Other color is
More...
 
Standard_Boolean operator== (const Quantity_Color &Other) const
 
Quantity_Parameter Light () const
 Returns the Light component (value of the lightness) of the
color <me>.
More...
 
Quantity_NameOfColor Name () const
 
 Returns the name of the color defined by its <br>

quantities of red R, green G and blue B; more
precisely this is the nearest color from the
Quantity_NameOfColor enumeration.
Exceptions
Standard_OutOfRange if R, G or B is less than 0. or greater than 1.
More...

 
Quantity_Parameter Red () const
 Returns the Red component (quantity of red) of the
color <me>.
More...
 
Quantity_Parameter Saturation () const
 Returns the Saturation component (value of the saturation)
of the color <me>.
More...
 
void Values (Quantity_Parameter &R1, Quantity_Parameter &R2, Quantity_Parameter &R3, const Quantity_TypeOfColor AType) const
 
 Returns in R1, R2 and R3 the components of <br>

this color according to the color system definition AType.
More...

 
Standard_ShortReal _CSFDB_GetQuantity_ColorMyRed () const
 
void _CSFDB_SetQuantity_ColorMyRed (const Standard_ShortReal p)
 
Standard_ShortReal _CSFDB_GetQuantity_ColorMyGreen () const
 
void _CSFDB_SetQuantity_ColorMyGreen (const Standard_ShortReal p)
 
Standard_ShortReal _CSFDB_GetQuantity_ColorMyBlue () const
 
void _CSFDB_SetQuantity_ColorMyBlue (const Standard_ShortReal p)
 

Static Public Member Functions

static void SetEpsilon (const Quantity_Parameter AnEpsilon)
 
Sets the specified value used to compare <me> and <br>
  an other color in IsDifferent and in IsEqual methods. <br>

Warning: The default value is 0.0001
More...

 
static Quantity_Parameter Epsilon ()
 Returns the specified value used to compare <me> and
an other color in IsDifferent and in IsEqual methods.
More...
 
static Quantity_NameOfColor Name (const Quantity_Parameter R, const Quantity_Parameter G, const Quantity_Parameter B)
 Returns the name of the colour for which the RGB components
are nearest to <R>, <G> and .
More...
 
static Standard_CString StringName (const Quantity_NameOfColor AColor)
 
  Returns the name of the color identified by <br>

AName in the Quantity_NameOfColor enumeration.
For example, the name of the color which
corresponds to Quantity_NOC_BLACK is "BLACK".
Exceptions
Standard_OutOfRange if AName in not known
in the Quantity_NameOfColor enumeration.
More...

 
static void HlsRgb (const Quantity_Parameter H, const Quantity_Parameter L, const Quantity_Parameter S, Quantity_Parameter &R, Quantity_Parameter &G, Quantity_Parameter &B)
 Converts HLS components into RGB ones.
More...
 
static void RgbHls (const Quantity_Parameter R, const Quantity_Parameter G, const Quantity_Parameter B, Quantity_Parameter &H, Quantity_Parameter &L, Quantity_Parameter &S)
 Converts RGB components into HLS ones.
More...
 
static void Color2argb (const Quantity_Color &theColor, Standard_Integer &theARGB)
 Convert the Color value to ARGB integer value.
theARGB has Alpha equal to zero, so the output is
formatted as 0x00RRGGBB
More...
 
static void Argb2color (const Standard_Integer theARGB, Quantity_Color &theColor)
 Convert integer ARGB value to Color. Alpha bits are ignored
More...
 
static void Test ()
 Internal test
More...
 

Detailed Description

This class allows the definition of a colour.
The names of the colours are from the X11 specification.
color object may be used for numerous applicative purposes.
A color is defined by:

Constructor & Destructor Documentation

Quantity_Color::Quantity_Color ( )

 Creates a colour with the default value of <br>
   Colour name : YELLOW <br>


Quantity_Color::Quantity_Color ( const Quantity_NameOfColor  AName)

 Creates the colour <AName>. <br>


Quantity_Color::Quantity_Color ( const Quantity_Parameter  R1,
const Quantity_Parameter  R2,
const Quantity_Parameter  R3,
const Quantity_TypeOfColor  AType 
)

 Creates a colour according to the definition system <br>
   TypeOfColor. <br>
   TOC_RGB : <R1> the value of red between 0. and 1. <br>
      <R2> the value of green between 0. and 1. <br>
      <R3> the value of blue between 0. and 1. <br>


TOC_HLS : <R1> is the hue angle in degrees, 0. being red
<R2> is the lightness between 0. and 1.
<R3> is the saturation between 0. and 1.

Member Function Documentation

Standard_ShortReal Quantity_Color::_CSFDB_GetQuantity_ColorMyBlue ( ) const
inline
Standard_ShortReal Quantity_Color::_CSFDB_GetQuantity_ColorMyGreen ( ) const
inline
Standard_ShortReal Quantity_Color::_CSFDB_GetQuantity_ColorMyRed ( ) const
inline
void Quantity_Color::_CSFDB_SetQuantity_ColorMyBlue ( const Standard_ShortReal  p)
inline
void Quantity_Color::_CSFDB_SetQuantity_ColorMyGreen ( const Standard_ShortReal  p)
inline
void Quantity_Color::_CSFDB_SetQuantity_ColorMyRed ( const Standard_ShortReal  p)
inline
static void Quantity_Color::Argb2color ( const Standard_Integer  theARGB,
Quantity_Color theColor 
)
static

Convert integer ARGB value to Color. Alpha bits are ignored

Quantity_Color& Quantity_Color::Assign ( const Quantity_Color Other)

Updates the colour <me> from the definition of the
colour <Other>.

Quantity_Parameter Quantity_Color::Blue ( ) const

Returns the Blue component (quantity of blue) of the
color <me>.

void Quantity_Color::ChangeContrast ( const Quantity_Rate  ADelta)

Increases or decreases the contrast by <ADelta>.
<ADelta> is a percentage. Any value greater than zero
will increase the contrast.
The variation is expressed as a percentage of the
current value.
It is a variation of the saturation.

void Quantity_Color::ChangeIntensity ( const Quantity_Rate  ADelta)

Increases or decreases the intensity by <ADelta>.
<ADelta> is a percentage. Any value greater than zero
will increase the intensity.
The variation is expressed as a percentage of the
current value.
It is a variation of the lightness.

static void Quantity_Color::Color2argb ( const Quantity_Color theColor,
Standard_Integer theARGB 
)
static

Convert the Color value to ARGB integer value.
theARGB has Alpha equal to zero, so the output is
formatted as 0x00RRGGBB

void Quantity_Color::Delta ( const Quantity_Color AColor,
Quantity_Parameter DC,
Quantity_Parameter DI 
) const

Returns the percentage change of contrast and intensity
between <me> and <AColor>.
<DC> and <DI> are percentages, either positive or negative.
The calculation is with respect to the current value of <me>
If <DC> is positive then <me> is more contrasty.
If <DI> is positive then <me> is more intense.

Standard_Real Quantity_Color::Distance ( const Quantity_Color AColor) const

Returns the distance between two colours. It's a
value between 0 and the square root of 3
(the black/white distance)

static Quantity_Parameter Quantity_Color::Epsilon ( )
static

Returns the specified value used to compare <me> and
an other color in IsDifferent and in IsEqual methods.

Quantity_Parameter Quantity_Color::Green ( ) const

Returns the Green component (quantity of green) of the
color <me>.

static void Quantity_Color::HlsRgb ( const Quantity_Parameter  H,
const Quantity_Parameter  L,
const Quantity_Parameter  S,
Quantity_Parameter R,
Quantity_Parameter G,
Quantity_Parameter B 
)
static

Converts HLS components into RGB ones.

Quantity_Parameter Quantity_Color::Hue ( ) const

Returns the Hue component (hue angle) of the
color <me>.

Standard_Boolean Quantity_Color::IsDifferent ( const Quantity_Color Other) const

Returns Standard_True if the distance between <me> and
<Other> is greater than Epsilon ().

Standard_Boolean Quantity_Color::IsEqual ( const Quantity_Color Other) const

Returns true if the Other color is

  • different from, or
  • equal to this color.
    Two colors are considered to be equal if their
    distance is no greater than Epsilon().
    These methods are aliases of operator != and operator ==.
Quantity_Parameter Quantity_Color::Light ( ) const

Returns the Light component (value of the lightness) of the
color <me>.

Quantity_NameOfColor Quantity_Color::Name ( ) const

 Returns the name of the color defined by its <br>

quantities of red R, green G and blue B; more
precisely this is the nearest color from the
Quantity_NameOfColor enumeration.
Exceptions
Standard_OutOfRange if R, G or B is less than 0. or greater than 1.

static Quantity_NameOfColor Quantity_Color::Name ( const Quantity_Parameter  R,
const Quantity_Parameter  G,
const Quantity_Parameter  B 
)
static

Returns the name of the colour for which the RGB components
are nearest to <R>, <G> and .

Standard_Boolean Quantity_Color::operator!= ( const Quantity_Color Other) const
inline
Quantity_Color& Quantity_Color::operator= ( const Quantity_Color Other)
inline
Standard_Boolean Quantity_Color::operator== ( const Quantity_Color Other) const
inline
Quantity_Parameter Quantity_Color::Red ( ) const

Returns the Red component (quantity of red) of the
color <me>.

static void Quantity_Color::RgbHls ( const Quantity_Parameter  R,
const Quantity_Parameter  G,
const Quantity_Parameter  B,
Quantity_Parameter H,
Quantity_Parameter L,
Quantity_Parameter S 
)
static

Converts RGB components into HLS ones.

Quantity_Parameter Quantity_Color::Saturation ( ) const

Returns the Saturation component (value of the saturation)
of the color <me>.

static void Quantity_Color::SetEpsilon ( const Quantity_Parameter  AnEpsilon)
static

Sets the specified value used to compare <me> and <br>
  an other color in IsDifferent and in IsEqual methods. <br>

Warning: The default value is 0.0001

void Quantity_Color::SetValues ( const Quantity_NameOfColor  AName)

Updates the colour <me> from the definition of the
colour <AName>.

void Quantity_Color::SetValues ( const Quantity_Parameter  R1,
const Quantity_Parameter  R2,
const Quantity_Parameter  R3,
const Quantity_TypeOfColor  AType 
)

 Updates a colour according to the mode specified by <br>
   TypeOfColor <br>
   TOC_RGB : <R1> the value of red between 0. and 1. <br>
      <R2> the value of green between 0. and 1. <br>
      <R3> the value of blue between 0. and 1. <br>


TOC_HLS : <R1> is the hue angle in degrees, 0. being red
<R2> is the lightness between 0. and 1.
<R3> is the saturation between 0. and 1.

Standard_Real Quantity_Color::SquareDistance ( const Quantity_Color AColor) const

Returns the square of distance between two colours.

static Standard_CString Quantity_Color::StringName ( const Quantity_NameOfColor  AColor)
static

  Returns the name of the color identified by <br>

AName in the Quantity_NameOfColor enumeration.
For example, the name of the color which
corresponds to Quantity_NOC_BLACK is "BLACK".
Exceptions
Standard_OutOfRange if AName in not known
in the Quantity_NameOfColor enumeration.

static void Quantity_Color::Test ( )
static

Internal test

void Quantity_Color::Values ( Quantity_Parameter R1,
Quantity_Parameter R2,
Quantity_Parameter R3,
const Quantity_TypeOfColor  AType 
) const

 Returns in R1, R2 and R3 the components of <br>

this color according to the color system definition AType.

  • if AType is Quantity_TOC_RGB R1 is the
    quantity of red, R2 is the quantity of green and
    R3 is the quantity of blue in this color.
  • if AType is Quantity_TOC_HLS R1 is the
    hue angle in degrees (0 being red), R2 is the
    lightness and R3 is the saturation of this color.

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